VBA OpenReport Action

  • Thread starter Thread starter none
  • Start date Start date
N

none

In the help documentation for the OpenReport Action, it gives the
following description for the Where Condition:
A valid SQL WHERE clause (without the word WHERE) or expression that
Access uses to select records from the report's underlying table or
query.

Can someone give me an example of a SQL where clause. I am not very
familiar with SQL, and have the the following:
(qQuery1.tTable1.[Yes-Internal]) <> Yes Or (qQuery1.tTable1.[Yes-
Internal]) Is Null

So that the full action reads:
DoCmd.OpenReport "rReport", acViewPreview, , (qQuery1.tTable1.[Yes-
Internal]) <> Yes Or (qQuery1.tTable1.[Yes-Internal]) Is Null

The error I get right now is 424 - Object Required.

Thank you!
 
The Where clause has to be a string. As well, you cannot include both the
name of a query (qQuery1) and the name of a table (tTable1).

Try:

DoCmd.OpenReport "rReport", acViewPreview, , "([Yes-Internal]) <> True Or
([Yes-Internal]) Is Null"

or, simpler

DoCmd.OpenReport "rReport", acViewPreview, , "Nz([Yes-Internal], False) <>
True"
 
Back
Top