DLOOKUP Problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

As you can probably guess, I am new to all this stuff so please bear with me. What I've got is a text box on a form and I have set its record source set to the following:

=DLookUp([QTYONHAND],"[PARTS]","[PARTNUMBER] = Forms![PARTSUSED1]")

where QTYONHAND is a number field, PARTS is my table containing the field QTYONHAND and PARTNUMBER is the other field on my PARTS form. PARTSUSED1 is the field on my current form and the data type is the same as PARTNUMBER in my table, they are Text Boxes. What I am trying to do is retrieve the QTYONHAND value from my PARTS table when the PARTSUSED1 value equals the PARTNUMBER value. What I get is the following in the text box where I want the value:
#Name?

If I attempt to adjust anything in the above function while my form is still open I get the following error:

The following doesn't contain the Automation object 'QTYONHAND'

Can someone please help? Thanks
 
Put double quotes around [QTYONHAND] ... and if [PARTSUSED] is a text field
then you will need to put single quotes around it as well

--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

JohnT said:
As you can probably guess, I am new to all this stuff so please bear with
me. What I've got is a text box on a form and I have set its record source
set to the following:
=DLookUp([QTYONHAND],"[PARTS]","[PARTNUMBER] = Forms![PARTSUSED1]")

where QTYONHAND is a number field, PARTS is my table containing the field
QTYONHAND and PARTNUMBER is the other field on my PARTS form. PARTSUSED1 is
the field on my current form and the data type is the same as PARTNUMBER in
my table, they are Text Boxes. What I am trying to do is retrieve the
QTYONHAND value from my PARTS table when the PARTSUSED1 value equals the
PARTNUMBER value. What I get is the following in the text box where I want
the value:
#Name?

If I attempt to adjust anything in the above function while my form is
still open I get the following error:
 
Copy the following and replace your expression ---

If PartNumber is a string:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = '" & Forms![PARTSUSED1] & "'")


If PartNumbe is numeric:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = " & Forms![PARTSUSED1])


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com




JohnT said:
As you can probably guess, I am new to all this stuff so please bear with me.
What I've got is a text box on a form and I have set its record source set to
the following:
=DLookUp([QTYONHAND],"[PARTS]","[PARTNUMBER] = Forms![PARTSUSED1]")

where QTYONHAND is a number field, PARTS is my table containing the field
QTYONHAND and PARTNUMBER is the other field on my PARTS form. PARTSUSED1 is the
field on my current form and the data type is the same as PARTNUMBER in my
table, they are Text Boxes. What I am trying to do is retrieve the QTYONHAND
value from my PARTS table when the PARTSUSED1 value equals the PARTNUMBER value.
What I get is the following in the text box where I want the value:
#Name?

If I attempt to adjust anything in the above function while my form is still
open I get the following error:
 
Ok, I tried both expressions and now I get a #ERROR in my text box. I believe it may be trying to identify the PARTSUSED1 as a form where as it is actually a field on a form called INVOICE. However, the help text I read in the program shows an example similar to this but says that where my PARTSUSED1 is should refer to that field on the current open form. I tried using Me! to try and show that I am trying to refer to the PARTSUSED1 field on the open form but then I just get #NAME in the text box. Do I need some kind of referrel to the form where my PARTSUSED1 field is located? Thanks

----- Mark wrote: ----

Copy the following and replace your expression --

If PartNumber is a string
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = '" & Forms![PARTSUSED1] & "'"


If PartNumbe is numeric
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = " & Forms![PARTSUSED1]


-
PC Datashee
Your Resource For Help With Access, Excel And Word Application
(e-mail address removed)
www.pcdatasheet.co




JohnT said:
As you can probably guess, I am new to all this stuff so please bear with me
What I've got is a text box on a form and I have set its record source set t
the following
=DLookUp([QTYONHAND],"[PARTS]","[PARTNUMBER] = Forms![PARTSUSED1]"
where QTYONHAND is a number field, PARTS is my table containing the fiel
QTYONHAND and PARTNUMBER is the other field on my PARTS form. PARTSUSED1 is th
field on my current form and the data type is the same as PARTNUMBER in m
table, they are Text Boxes. What I am trying to do is retrieve the QTYONHAN
value from my PARTS table when the PARTSUSED1 value equals the PARTNUMBER value
What I get is the following in the text box where I want the value
 
John,

Sorry my mistake!!

Try the appropriate statement ---

If PartNumber is a string:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = '" & Forms!Invoice![PARTSUSED1]
& "'")


If PartNumbe is numeric:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = " & Forms!Invoice![PARTSUSED1])

Steve
PC Datasheet


JohnT said:
Ok, I tried both expressions and now I get a #ERROR in my text box. I believe
it may be trying to identify the PARTSUSED1 as a form where as it is actually a
field on a form called INVOICE. However, the help text I read in the program
shows an example similar to this but says that where my PARTSUSED1 is should
refer to that field on the current open form. I tried using Me! to try and show
that I am trying to refer to the PARTSUSED1 field on the open form but then I
just get #NAME in the text box. Do I need some kind of referrel to the form
where my PARTSUSED1 field is located? Thanks
----- Mark wrote: -----

Copy the following and replace your expression ---

If PartNumber is a string:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = '" & Forms![PARTSUSED1] & "'")


If PartNumbe is numeric:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = " & Forms![PARTSUSED1])


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com




JohnT said:
As you can probably guess, I am new to all this stuff so please bear
with me.
What I've got is a text box on a form and I have set its record source set to
the following:
=DLookUp([QTYONHAND],"[PARTS]","[PARTNUMBER] = Forms![PARTSUSED1]")
where QTYONHAND is a number field, PARTS is my table containing the
field
QTYONHAND and PARTNUMBER is the other field on my PARTS form. PARTSUSED1 is the
field on my current form and the data type is the same as PARTNUMBER in my
table, they are Text Boxes. What I am trying to do is retrieve the QTYONHAND
value from my PARTS table when the PARTSUSED1 value equals the PARTNUMBER value.
What I get is the following in the text box where I want the value:
still
open I get the following error:
 
Ok, I tried both expressions and now I get a #ERROR in my text box.
I believe it may be trying to identify the PARTSUSED1 as a form
where as it is actually a field on a form called INVOICE.
However, the help text I read in the program shows an example
similar to this but says that where my PARTSUSED1 is should
refer to that field on the current open form. I tried using Me!
to try and show that I am trying to refer to the PARTSUSED1
field on the open form but then I just get #NAME in the text
box. Do I need some kind of referrel to the form where my
PARTSUSED1 field is located? Thanks

----- Mark wrote: -----

Copy the following and replace your expression ---

If PartNumber is a string:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = '" & Forms![PARTSUSED1] & "'")


If PartNumbe is numeric:
=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = " & Forms![PARTSUSED1])

1) You can NOT use the Me! keyword within an Access Control Source.
Me! is a VBA keyword, not an Access key word.

2) If the [PartsUsed1] control is located on the same form ([Invoice])
as this DLookUp control, then you do not need to specifically refer to
the form.

3) The Correct syntax for your DLookUp, assuming [PartNumber] and
[PartsUsed1] are both text DATATYPE (not necessarily Text Boxes as
your original post called them) is:

=DLookUp("[QTYONHAND]","[PARTS]","[PARTNUMBER] = '" & [PARTSUSED1] &
"'")

4) *** Make sure the NAME of this control is not the same as the name
of any field used within it's control source expression. ***



Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com




JohnT said:
As you can probably guess, I am new to all this stuff so please bear with me.
What I've got is a text box on a form and I have set its record source set to
the following:
=DLookUp([QTYONHAND],"[PARTS]","[PARTNUMBER] = Forms![PARTSUSED1]")
where QTYONHAND is a number field, PARTS is my table containing the field
QTYONHAND and PARTNUMBER is the other field on my PARTS form. PARTSUSED1 is the
field on my current form and the data type is the same as PARTNUMBER in my
table, they are Text Boxes. What I am trying to do is retrieve the QTYONHAND
value from my PARTS table when the PARTSUSED1 value equals the PARTNUMBER value.
What I get is the following in the text box where I want the value:
 
Back
Top