DoCmd.OpenReport WHERE clause syntax

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

Guest

I am trying to print a simple nametag using the following syntax:

DoCmd.OpenReport "NameTag", acViewNormal, , VID=lngVID

VID refers to a field name and lngVID is a variable (long integer). The
result of this line of code is a single printed nametag with #Error printing
instead of [Name] as specified in the report (though that doesn't happen when
running the report manually).

Any help would be much appreciated!
 
cicerone said:
I am trying to print a simple nametag using the following syntax:

DoCmd.OpenReport "NameTag", acViewNormal, , VID=lngVID

VID refers to a field name and lngVID is a variable (long integer).
The result of this line of code is a single printed nametag with
#Error printing instead of [Name] as specified in the report (though
that doesn't happen when running the report manually).

Any help would be much appreciated!

The WhereCondition is a string arguement, so you need to pass it a
string, which is constructed as a valid SQL WHERE clause without the
keyword WHERE, so

DoCmd.OpenReport "NameTag", acViewNormal, , "VID=" & lngVID

would probably do the trick
 
Back
Top