DLookup failing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I cannot figure out what to put in my String Expression. It fails at
"strUserPassword"...

This is my code:

Private Sub cmdLogin_Click()

'Check to see if data is entered into the RACF combo box cboUser

If IsNull(Me.cboUser) Or Me.cboUser = "" Then
MsgBox "You must enter a RACF.", vbOKOnly, "Required Data"
Me.cboUser.SetFocus
Exit Sub
End If



'Check to see if data is entered into the password box txtPassword

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If


'Check value of password in t_Users to see if this
'matches value chosen in txtPassword combo box


If Me.txtPassword.Value = DLookup("strUserPassword", "t_Users", "[RACFID]="
& Me.cboUser.Value) Then
lngMyRACFID = Me.cboUser.Value

'Close login form and open splash screen

DoCmd.Close acForm, "f_Login", acSaveNo
DoCmd.OpenForm "f_Splash"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
 
If the RACFID field type is text, you need to add a single column before and
after the criteria

DLookup("strUserPassword", "t_Users", "[RACFID]='" & Me.cboUser.Value & "'")
 
I did and get the same error:
Runtime Error 2471.
The object doesn't contain Automation Object 'strUserPassword'

Suggestions???



Ofer Cohen said:
If the RACFID field type is text, you need to add a single column before and
after the criteria

DLookup("strUserPassword", "t_Users", "[RACFID]='" & Me.cboUser.Value & "'")

--
Good Luck
BS"D


Dan @BCBS said:
I cannot figure out what to put in my String Expression. It fails at
"strUserPassword"...

This is my code:

Private Sub cmdLogin_Click()

'Check to see if data is entered into the RACF combo box cboUser

If IsNull(Me.cboUser) Or Me.cboUser = "" Then
MsgBox "You must enter a RACF.", vbOKOnly, "Required Data"
Me.cboUser.SetFocus
Exit Sub
End If



'Check to see if data is entered into the password box txtPassword

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If


'Check value of password in t_Users to see if this
'matches value chosen in txtPassword combo box


If Me.txtPassword.Value = DLookup("strUserPassword", "t_Users", "[RACFID]="
& Me.cboUser.Value) Then
lngMyRACFID = Me.cboUser.Value

'Close login form and open splash screen

DoCmd.Close acForm, "f_Login", acSaveNo
DoCmd.OpenForm "f_Splash"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
 
What is the field name? Is it strUserPassword or is it UserPassword or is
it Password? Your first argument should be the name of the field.
 
Is the strUserPassword the right field name from the table t_Users, check the
syntax.

--
Good Luck
BS"D


Dan @BCBS said:
I did and get the same error:
Runtime Error 2471.
The object doesn't contain Automation Object 'strUserPassword'

Suggestions???



Ofer Cohen said:
If the RACFID field type is text, you need to add a single column before and
after the criteria

DLookup("strUserPassword", "t_Users", "[RACFID]='" & Me.cboUser.Value & "'")

--
Good Luck
BS"D


Dan @BCBS said:
I cannot figure out what to put in my String Expression. It fails at
"strUserPassword"...

This is my code:

Private Sub cmdLogin_Click()

'Check to see if data is entered into the RACF combo box cboUser

If IsNull(Me.cboUser) Or Me.cboUser = "" Then
MsgBox "You must enter a RACF.", vbOKOnly, "Required Data"
Me.cboUser.SetFocus
Exit Sub
End If



'Check to see if data is entered into the password box txtPassword

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If


'Check value of password in t_Users to see if this
'matches value chosen in txtPassword combo box


If Me.txtPassword.Value = DLookup("strUserPassword", "t_Users", "[RACFID]="
& Me.cboUser.Value) Then
lngMyRACFID = Me.cboUser.Value

'Close login form and open splash screen

DoCmd.Close acForm, "f_Login", acSaveNo
DoCmd.OpenForm "f_Splash"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
 
It's Password and I know I tried Password...

I just tried it again and it's working fine...

Thanks


John Spencer said:
What is the field name? Is it strUserPassword or is it UserPassword or is
it Password? Your first argument should be the name of the field.
Dan @BCBS said:
I cannot figure out what to put in my String Expression. It fails at
"strUserPassword"...

This is my code:

Private Sub cmdLogin_Click()

'Check to see if data is entered into the RACF combo box cboUser

If IsNull(Me.cboUser) Or Me.cboUser = "" Then
MsgBox "You must enter a RACF.", vbOKOnly, "Required Data"
Me.cboUser.SetFocus
Exit Sub
End If



'Check to see if data is entered into the password box txtPassword

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If


'Check value of password in t_Users to see if this
'matches value chosen in txtPassword combo box


If Me.txtPassword.Value = DLookup("strUserPassword", "t_Users",
"[RACFID]="
& Me.cboUser.Value) Then
lngMyRACFID = Me.cboUser.Value

'Close login form and open splash screen

DoCmd.Close acForm, "f_Login", acSaveNo
DoCmd.OpenForm "f_Splash"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
 

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

Back
Top