dlookup

S

sam

I have a bound form and am wanting to display a field from a query on the
form. I think I could use dlookup for a table but could someone tell me what
method would be best to use (or if it's possible) to look up a value in a
query?

(The record ID on the form will match the Record ID in the query)
 
J

John W. Vinson

I have a bound form and am wanting to display a field from a query on the
form. I think I could use dlookup for a table but could someone tell me what
method would be best to use (or if it's possible) to look up a value in a
query?

DLookUp works exactly the same with a query as it does with a table. Just use
the name of the query as the second argument of the DLookUp, and the
(optional) criteria as the third:

=DLookUp("[fieldname]", "[queryname]", "[ID] = " & txtID)
 
S

sam

Thanks John. I haven't been able to get dlookup to work... but wasn't sure if
it would work with a query. Must have just got something wrong. Will try
again now i know it will work with a query. Thanks.
--
Thanks


John W. Vinson said:
I have a bound form and am wanting to display a field from a query on the
form. I think I could use dlookup for a table but could someone tell me what
method would be best to use (or if it's possible) to look up a value in a
query?

DLookUp works exactly the same with a query as it does with a table. Just use
the name of the query as the second argument of the DLookUp, and the
(optional) criteria as the third:

=DLookUp("[fieldname]", "[queryname]", "[ID] = " & txtID)
 
F

fredg

Thanks John. I haven't been able to get dlookup to work... but wasn't sure if
it would work with a query. Must have just got something wrong. Will try
again now i know it will work with a query. Thanks.

If you can't get it to work, then post the exact DLookUp expression
you are using. Include the datatype of the criteria field.
Also, make sure the name of the control on the form is NOT the same as
the name of any field used in the expression.
 

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

Top