Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup Error

Status
Not open for further replies.

longhair

MIS
Feb 7, 2001
889
US
I'm having an issue with some DLookup code that I wrote & was looking for some suggestions on a solution. The error that I receive when run is:
Run-Time error '2471'
The expression you encountered as a query parameter produced this error: 'The object doesn't contain the automation object 'Smith.''
The code is as follows:

Private Sub Last_Name_Change()
Dim X As String
Dim Y As String
X = Forms![Service Table Form]![Last Name].Value
Y = DLookup("[First Name]", "Customer", _
"[Last Name] = " & X)
First_Name.SetFocus
First_Name.Value = Y

End Sub

This code structure has worked fine for me when looking up integers. [Last Name] on the [Service Table Form] is a combo box that looks up entries in the [Customer] table, so I know the entries are there. X populates fine but Y is never populated because of the error. Any ideas?

Thank you in advance.

Dave
 
Looks like you only need to see the first name on the form. How about adding a textbox whos Control Source is:
=DLookup("[First Name]", "Customer","[Last Name] = Forms![Service Table Form]![Last Name]")
If this is the case scrap the bound [First Name] field. Give 'er a try...
Gord
ghubbell@total.net
 
Even though you may be displaying the last name in the combobox it may be bound to the primary key of the table. You might try this instead:

Y = DLookup("[First Name]", "Customer", _
"[CustomerID] = " & X)

Where 'CustomerID' is the actual name of the primary key field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top