Error 3219

G

Guest

Ok. I figured it out on my own, but I want to know why. I am using the code
I received from Lynn's link on password protectig a form. The code is from a
Mocrosft site. I installed it just like the directions and it worked no
problem. The forms were protected and everything cruised.

Now, I moved the table to the backend of the database and received a error
3219 when I tried to open the form. Below is the code for you guys to look
at, but I wanted to know why the coding caused the error when I moved the
table of passwords to the backend database.

Just curious.
--
Thanks As Always
Rip


Private Sub Form_Open(Cancel as Integer)
Dim Hold As Variant
Dim tmpKey As Long
Dim I As Integer
Dim rs As DAO.Recordset
Dim db As DAO.Database

On Error GoTo Error_Handler
' Prompt the user for the Password.
DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog
Hold = MyPassword
' Open the table that contains the password.
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPassword", dbOpenTable)
rs.Index = "PrimaryKey"
rs.Seek "=", Me.Name
If rs.NoMatch Then
MsgBox "Sorry cannot find password information. Try Again"
Cancel = -1
Else
' Test to see if the key generated matches the key in
' the table; if there is not a match, stop the form
' from opening.
If Not (rs![keycode] = KeyCode(Cstr(Hold))) Then
MsgBox "Sorry you entered the wrong password." & _
"Try again.", vbOKOnly, "Incorrect Password"
Cancel = -1
End If
End If
rs.Close
db.Close
Exit Sub

Error_Handler:
MsgBox Err.Description, vbOKOnly, "Error #" & Err.Number
Exit Sub
End Sub
 
V

Van T. Dinh

IIRC, you cannot use dbOpenTable on a linked Table. In fact, you cannot use
Seek either unless you use code to open the BackEnd.

The sample code from Microsoft probably used a local Table and not linked
Table.

Simple to use Dynaset and FindFirst if you want to use linked Table..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top