I am trying to retrieve a text string within a table using Dlookup. It is for a password entry field. Goes like this...:
Private Sub Command3_Click()
Dim StrPersPass As String
Dim StrPassword As String
StrPersPass = DLookup("Password", "tblpasswords", "Function" = "PersonnelPassword")
If IsNull(Me.PasswordBox) Then
MsgBox "You must enter a password, or Cancel", vbOKOnly
Me.PasswordBox = ""
StrPassword = Me.PasswordBox
If StrPassword = StrPersPass Then
DoCmd.Close acForm, "frmPersonnelPassword"
MsgBox "Your password is incorrect and your attempt has been logged.", vbOKOnly, vbCritical
When I run the event, I get error 94 'Invalis use of Null'. For some reason strPersPass returns a value of Null. All fields are text format. I placed the MsgBox StrPersPass to return the value of strPersPass, and the message box is always blank!!
If I change the syntax to: StrPersPass = DLookup("Password", "tblpasswords", "Function=" & "PersonnelPassword") I get Runtime error 2471 -'The object doesn't contain the Automation object "PersonnelPassword"'
All the names are correct, and the table has the relevant infomation... What am I doing wrong...?!?