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  

How do I use dlookup in a form to find a specific field



 
 
Thread Tools Display Modes
  #1  
Old March 26th, 2010, 04:56 PM posted to microsoft.public.access.forms
Josh
external usenet poster
 
Posts: 236
Default How do I use dlookup in a form to find a specific field

I have a textbox with the following control source:

Code:
=DLookUp("[Heater Type]","Washers","[Model Number] =
LabelModelNumber.caption)"

So basically I am trying to look up the heater type from the washers table
by the model number. On the form I have it so the user select the type of
washer they want and it displays the model number on the form via a label.

It appears to just be grabbing the first item in the heater type field, so
"labelmodelnumber.caption" must be the problem, but I can figure out what I
need to change it too.
  #2  
Old March 26th, 2010, 06:08 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default How do I use dlookup in a form to find a specific field

Josh -

You need to evaluate the LabelModelNumber.caption outside of the
double-quotes, and add in the single-quote delimeters if it is a text field.
Try this:

=DLookUp("[Heater Type]","Washers","[Model Number] = '" &
LabelModelNumber.caption & "'")

If Model Number is a number field, then use this:

=DLookUp("[Heater Type]","Washers","[Model Number] = " &
LabelModelNumber.caption )

--
Daryl S


"Josh" wrote:

I have a textbox with the following control source:

Code:
=DLookUp("[Heater Type]","Washers","[Model Number] =
LabelModelNumber.caption)"

So basically I am trying to look up the heater type from the washers table
by the model number. On the form I have it so the user select the type of
washer they want and it displays the model number on the form via a label.

It appears to just be grabbing the first item in the heater type field, so
"labelmodelnumber.caption" must be the problem, but I can figure out what I
need to change it too.

 




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 05:10 PM.


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