dlookup challanges


C

crmulle

I am struggling with a general lookup function. I want the user to be able
to look up a vendor id or name from field with in a form and have the form
populate with the correct vendor information. The fields (ex. Vendor ID,
Owning LOB, Risk Rating, Service Category, etc.) in this form are bound to a
table named tblImport This information in this table is static and doesn't
change until the monthly upload is complete. Therefore, a user shouldn't be
able to edit the information

When I set up a combo box it allows me to edit the Vendor ID field (which
changes the tblImport table) and doesn't populate the other fields properly
in the form.

I tried using a dlookup and am stuck. I have included my code below, but I
am not understanding the help information on dlookup...specifically the
criteria portion of the dlookup. Would someone be able to give me some
direction on how to resolve this?

DLookup("[Vendor ID]", tblImport, "[Vendor ID]" = Forms!frmMain2!VendorId)

PS - I even tried using an input box but they only accept strings and not
numbers...correct? I have included my code for that as well.

Dim strVendorId As Variant

strVendorId = InputBox("Please enter the desired Vendor ID:", "Find")

DoCmd.GoToRecord "strVendorId"
 
Ad

Advertisements

D

Douglas J. Steele

Try putting the equal sign inside the quotes:

DLookup("[Vendor ID]", tblImport, "[Vendor ID] = " &
Forms!frmMain2!VendorId)

For the second option, putting the quotes around strVendorId means that it's
going to use that literal string. However, even if you removed the quotes
from around strVendorId in the GoToRecord method, it's not going to work,
because GoToRecord works with instruction telling it how many records you
want to move, not to move to a record with a specific value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top