Reference a field from a query in Visual Basic code

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

Guest

I need to be able to look at a field in a query result behind the Print event
for a report and set an attribute based on what's in the field. What's the
syntax in VB for referencing a field in an Access query?
 
I need to be able to look at a field in a query result behind the Print event
for a report and set an attribute based on what's in the field. What's the
syntax in VB for referencing a field in an Access query?

If the query is NOT the report's record source you can use DLookUp.
=DLookUp("[FieldName]","Queryname")

If there is more than one record returned in the query, you'll need to
add a where clause to the expression.
Look up the DLookUp() function in VBA help.
 
Back
Top