Problem pulling info from a table for use in vb code

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

Guest

Hello,
I was wondering whether someone could please help me.
I have been working on a form which asks the user to enter a password based on the employee ID number which they enter in an input box.
I am trying to draw the correct password information from a table containing employee information but keep receiving the following error message on running:
Run-time error '2471
The expression you entered as a query parameter produced this error:
'The object doesn't contain the Automation object 'G01."
G01 was the inputed Employee ID and this is held within the EmployeeID field of the table EmployeeInfo

The code I am using as a test is shown below:
Private Sub Form_Open(Cancel As Integer)
Dim correct As String
Dim employee As String
employee = InputBox("Please enter your Employee ID", "Employee ID")
correct = DLookup("Password", "EmployeeInfo", "EmployeeID = " & employee)
Message = MsgBox("value is " & correct)
End Sub

Any help on getting this to work would be much appreciated
Many thanks
 
if Employee is a string
correct = DLookup("Password", "EmployeeInfo", "EmployeeID = '" & employee &
"'")

Based on the error I would also check the table Employee contains fields
called Password and EmployeeID


James said:
Hello,
I was wondering whether someone could please help me.
I have been working on a form which asks the user to enter a password
based on the employee ID number which they enter in an input box.
I am trying to draw the correct password information from a table
containing employee information but keep receiving the following error
message on running:
Run-time error '2471
The expression you entered as a query parameter produced this error:
'The object doesn't contain the Automation object 'G01."
G01 was the inputed Employee ID and this is held within the EmployeeID
field of the table EmployeeInfo
 
Hi John
The code that you suggested worked
Many thanks for your help with this.
 

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