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
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