DoCmd.OpenReport WHERE clause syntax

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!
 
R

RoyVidar

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
 

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