If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
dlookup challanges
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" |
#2
|
|||
|
|||
dlookup challanges
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. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "crmulle" wrote in message ... 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" |
Thread Tools | |
Display Modes | |
|
|