dlookup problem

Gregc

Board Regular
Joined
Apr 24, 2002
Messages
75
I have an on change event in a text box that uses dlookup to retrieve some values from a table. Following is the code I used. I am getting the address from the Hotel table where teh job number is p11792.

JobName = DLookup("[strAddress]", "tblHotel", "[strJobNumber]= P11792")

This is the error message I get: Run-time error '2471':
The expression you entered as a query parameter produced this error: 'The object doesn't contain the Automation object 'P11792."

The code appears to be correct to me. I have used Dlookup before, with no problem.

I would be greatly apprecitive if anyone can point out the problem.

Thanks,
Greg
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try this:

DLookup("[strAddress]", "tblHotel", "[strJobNumber]= 'P11792'")

Since strJobNumber is a text field, you'll need the single quotes around the value you're trying to find.

-Russell
 
Upvote 0
Thanks for the help Russell. It has been awhile since I have done much VBA and I tend to forget some things after awhile.

Greg
 
Upvote 0

Forum statistics

Threads
1,221,575
Messages
6,160,603
Members
451,657
Latest member
Ang24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top