dlookup

  • Thread starter Thread starter sam
  • Start date Start date
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)
 
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)
 
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)
 
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.
 
Back
Top