runtime error

krishnanhemanth

Registered User.
Local time
Today, 16:16
Joined
Jun 12, 2009
Messages
115
i get a runtime error 2471 -- the expression you enterd as a query parameter produced this error :
on the following code

Private Sub ENTER_Click()
'Check to see if data is entered into the UserName combo box

If IsNull(Me.sboard) Or Me.sboard = "" Then
MsgBox "You must select a module.", vbOKOnly, "DREAMKRAFTS"
Me.sboard.SetFocus
Exit Sub
End If

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

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

'Check value of password in tbl switchboardpasswords to see if this matches value chosen in combo box

If Me.password.value = DLookup("sbpassword", "switchboardpasswords", "[sbid]=" & Me.sboard.value) Then

sbid = Me.sboard.value

'Close logon form and open splash screen


DoCmd.OpenForm Me.sboard

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


table switchboardpasswords
sbid -- switchboard id autonumber
switchboard - name of the switchboards
sbpassword - assigned passwords

on the form
sboard - combobox with values from the table switchboardpasswords
password - unbound textbox where user enters the password


please help

krishnanhemanth
 
If your sboard value is a text field then you need to surround it with single quotes.
Code:
If Me.password.value = DLookup("[sbpassword]", "switchboardpasswords", "[sbid]=" & "'" & Me.sboard.value & "'") Then

Also, you can check for nulls and empty strings with Nz...
Code:
If Nz(Me.password) = "" Then
 
HI GHUDSON

i used this code below

Private Sub ENTER_Click()
'Check to see if data is entered into the UserName combo box

If IsNull(Me.sboard) Or Me.sboard = "" Then
MsgBox "You must select a module.", vbOKOnly, "DREAMKRAFTS"
Me.sboard.SetFocus
Exit Sub
End If

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

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

'Check value of password in tbl switchboardpasswords to see if this matches value chosen in combo box
If Me.password.value = DLookup("[sbpassword]", "switchboardpasswords", "[switchboard]=" & "'" & Me.sboard & "'") Then



'Close logon form and open splash screen

DoCmd.OpenForm Me.sboard
DoCmd.CLOSE acForm, "switchboard what to do"


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

the code is not executing the line shown in red
 

Users who are viewing this thread

Back
Top Bottom