asswords

R

Roger Bell

I have written the following code to open a Form "Onclick Event procedure"
When I run the command I get the error message "Unable to find TblPassword"
Would appreciate any help_Thanks
Private Sub ENTER_PG_Click()


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ENTER PLANNED GIVING"
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.

' 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
 
K

Keith Wilby

Roger Bell said:
I have written the following code to open a Form "Onclick Event procedure"
When I run the command I get the error message "Unable to find
TblPassword"
Would appreciate any help_Thanks
Private Sub ENTER_PG_Click()
<snip>

Hi Roger,

Silly questions:

Is TblPassword a table? If it's a query then AIUI you can't use the
dbOpenTable argument.
If TblPassword is a table, is it in your database or do you have a link to
it?

Keith.
www.keithwilby.com
 

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

Top