A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

dlookup challanges



 
 
Thread Tools Display Modes
  #1  
Old April 30th, 2008, 08:59 PM posted to microsoft.public.access.forms
crmulle
external usenet poster
 
Posts: 11
Default 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  
Old April 30th, 2008, 10:17 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:18 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.