Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DLookup Error

DLookup Error

DLookup Error

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

Replies continue below

Recommended for you

RE: DLookup Error

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


RE: DLookup Error

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close