DLookup

J

Jim Eccles

I am trying to Access a field in a table using DLookup
and it refuses to work. I am putting into the Control
Source property - =DLookup("R1Low","Model Range Power
Output","ModelNumber = Form![Todays Data]!ModelNumber")
The problem is in the syntax of the criteria portion.
I have tried the - "[ModelNumber =" & Forms![Model Range
Power Output]![ModelNumber])
I need the field R1Low (The Low Range for reading #1) in
the table that is on the same row as the selected
ModelNumber on the data entry form "Todays Data"

I am using Office 2000
This is my first usage of this forum
 
M

Mike Painter

Jim Eccles said:
I am trying to Access a field in a table using DLookup
and it refuses to work. I am putting into the Control
Source property - =DLookup("R1Low","Model Range Power
Output","ModelNumber = Form![Todays Data]!ModelNumber")
The problem is in the syntax of the criteria portion.
I have tried the - "[ModelNumber =" & Forms![Model Range
Power Output]![ModelNumber])
I need the field R1Low (The Low Range for reading #1) in
the table that is on the same row as the selected
ModelNumber on the data entry form "Todays Data"
If Model Number is text it must be enclosed in quotes.
"[ModelNumber = '" & Forms![Model Range Power Output]![ModelNumber] &"'"
That's single quote, double quote before the first "&" and double quote,
single quote, double quote at the end.
 
D

DanK

Try this:
=DLookup("[R1Low]","[Model Range Power
Output]","[ModelNumber] = Forms![Todays Data]!
[ModelNumber]")

email me if you need to.
 
J

Jim Eccles

-----Original Message-----

Jim Eccles said:
I am trying to Access a field in a table using DLookup
and it refuses to work. I am putting into the Control
Source property - =DLookup("R1Low","Model Range Power
Output","ModelNumber = Form![Todays Data]!ModelNumber")
The problem is in the syntax of the criteria portion.
I have tried the - "[ModelNumber =" & Forms![Model Range
Power Output]![ModelNumber])
I need the field R1Low (The Low Range for reading #1) in
the table that is on the same row as the selected
ModelNumber on the data entry form "Todays Data"
If Model Number is text it must be enclosed in quotes.
"[ModelNumber = '" & Forms![Model Range Power Output]! [ModelNumber] &"'"
That's single quote, double quote before the first "&" and double quote,
single quote, double quote at the end.

First - Thanks for responding.
=DLookUp("[r1low]","Model Range Power Output",
["ModelNumber =' "] & [Forms]![Todays Data]![ModelNumber]
& " ' ") is still missing something. It is not
recognising that the form I have running is named [Todays
Data] as valid
 
M

Mike Painter

Jim Eccles said:
-----Original Message-----

Jim Eccles said:
I am trying to Access a field in a table using DLookup
and it refuses to work. I am putting into the Control
Source property - =DLookup("R1Low","Model Range Power
Output","ModelNumber = Form![Todays Data]!ModelNumber")
The problem is in the syntax of the criteria portion.
I have tried the - "[ModelNumber =" & Forms![Model Range
Power Output]![ModelNumber])
I need the field R1Low (The Low Range for reading #1) in
the table that is on the same row as the selected
ModelNumber on the data entry form "Todays Data"
If Model Number is text it must be enclosed in quotes.
"[ModelNumber = '" & Forms![Model Range Power Output]! [ModelNumber] &"'"
That's single quote, double quote before the first "&" and double quote,
single quote, double quote at the end.

First - Thanks for responding.
=DLookUp("[r1low]","Model Range Power Output",
["ModelNumber =' "] & [Forms]![Todays Data]![ModelNumber]
& " ' ") is still missing something. It is not
recognising that the form I have running is named [Todays
Data] as valid

I learned a long time ago not to put spaces in the names of anything. Are
you sure it's "Todays data" and not "todays data"?
If the call is in this form Me!modelnumber will work.
You also have included spaces in the quote marks which may be a problem.
 
P

PC Datasheet

Jim,

Name your textbox LowRangeReadingNum1. If ModelNumber is numeric, put this
expression in its control source:
=DLookup("[R1Low]","Model Range PowerOutput","[ModelNumber] = " & Form!Todays
Data!ModelNumber)

If ModelNumber is a string, put this expression in its control source:
=DLookup("[R1Low]","Model Range PowerOutput","[ModelNumber] = '" & Form!Todays
Data!ModelNumber & "'")

If the purpose of your form is to display values already in your table, the
above will work as is. If your form is for data entry, put this expression in
the AfterUpdate event of the ModelNumber textbox:
Me!LowRangeReadingNum1.Requery
 
J

John Vinson

["ModelNumber =' "] & [Forms]![Todays Data]![ModelNumber]
& " ' ") is still missing something. It is not
recognising that the form I have running is named [Todays
Data] as valid

Two suggestions:

- Is the form Todays Data open at the time you're opening this query?
It needs to be, or else it will indeed prompt you.

- You've got some extra blanks which need to be removed, and some
misplaced quotes. The line should be

"[ModelNumber] ='" & [Forms]![Todays Data]![ModelNumber] & "'")

This will concatenate three strings:

[ModelNumber] ='
XYZ123 << or whatever you put in ModelNumber
'

to create a string

[ModelNumber ='XYZ123'
 

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