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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup

Status
Not open for further replies.

melisc

Programmer
Feb 6, 2004
15
US
I am creating a database for a vendor and I am trying to get one field on a form to lookup a value from a table. The other fields already run on macros and are just used to populate dollar amounts. I need the county ID to populate automatically based on the Vendor name. Does anyone know the correct command or procedure for this command to run?

Thanks.
 
I think this example may help it uses the DLookup function. Just change the table and field names to suit you.

varcountyID = DLookup("countyID", "tblVendors", "vendorName ='" & [vendorName] & "'")

countyID.text = varcountyID

You would put this in the on update section of the field containing the vendor name.

Hope it helps :)
 
Thanks a bunch for the help. This is the command that I wrote:


=DLookUp("countyID","locations","location ID ='" & [Location ID] & "'")


It is returning an error to me.

It is a form that is linked to query. The [Location ID] is the field that is populated with the Vendor name and the [County Id] is the field that I want to self populate based on the data in the[LocationID] field. The table that I need it to lookup from is named [locations]

Does it make a difference if I am looking by the ID associated with the name? The combo box has the Location ID and the Location Name although I hid the Location ID so that there was no confusion. I am also trying to lookup by Table even though the form runs off of a query, is that OK?

Thanks again for your help!





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top