Syntax Where Condition in Macro

J

JackG

I have a report based on a query. The query has a criteria set ('Program'
field from 'Client' Table needs to select records with crieteria of
"highroad" Or "Aftercare". The query runs fine alone and picks records from
'Client' where the 'Program' field contains "highroad" Or "Aftercare". The
report runs fine. When I call the report from a macro (OpenReport) I am
being prompted for the parameters for the 'Program' field?

What do I need to do. If the answer is set the With Condition on the
OpenReport macro, what is the syntax and do I remove the criteria from the
query? Table = Client, Field=Program, Values "Highroad" Or "Aftercare"
Query=Query-AllClients, Report = Report-AllClients. Please help, I have
tired everything I know and nothing is working. What is the syntax for an
expression in the With Condition of an OpenReport Macro.
I am using Access 2003.

Thank You,

Jack G.
 
N

nik

Fahsjhdskfhklsdf



Jack:

On the information you've provided I can't see why you should be
prompted for parameters when opening the report via a macro. If you
can open the report from the database window, then it should open via
a macro. Odd!

When using the WhereCondition setting of the OpenReport method in
code, or the same action in a macro you don't need the criteria in the
query, so you can delete them. In the macro the expression for the
WhereCondition setting is:

[Program] = "Highroad" Or [Program] = "Aftercare"

BTW if you do the same thing in code the expression would be:

"[Program] = ""Highroad"" Or [Program] = ""Aftercare"""

This is because the WhereCondition is a string expression so needs to
be enclosed in quotes characters. The quotes characters around the
two values consequently need to be doubled up as this is how a literal
quotes character is included in a string already delimited by quotes
characters.

Ken Sheridan
Stafford, England

I have a report based on a query. The query has a criteria set ('Program'
field from 'Client' Table needs to select records with crieteria of
"highroad" Or "Aftercare". The query runs fine alone and picks records from
'Client' where the 'Program' field contains "highroad" Or "Aftercare". The
report runs fine. When I call the report from a macro (OpenReport) I am
being prompted for the parameters for the 'Program' field?

What do I need to do. If the answer is set the With Condition on the
OpenReport macro, what is the syntax and do I remove the criteria from the
query? Table = Client, Field=Program, Values "Highroad" Or "Aftercare"
Query=Query-AllClients, Report = Report-AllClients. Please help, I have
tired everything I know and nothing is working. What is the syntax for an
expression in the With Condition of an OpenReport Macro.
I am using Access 2003.

Thank You,

Jack G.
 
K

ken

Jack:

On the information you've provided I can't see why you should be
prompted for parameters when opening the report via a macro. If you
can open the report from the database window, then it should open via
a macro. Odd!

When using the WhereCondition setting of the OpenReport method in
code, or the same action in a macro you don't need the criteria in the
query, so you can delete them. In the macro the expression for the
WhereCondition setting is:

[Program] = "Highroad" Or [Program] = "Aftercare"

BTW if you do the same thing in code the expression would be:

"[Program] = ""Highroad"" Or [Program] = ""Aftercare"""

This is because the WhereCondition is a string expression so needs to
be enclosed in quotes characters. The quotes characters around the
two values consequently need to be doubled up as this is how a literal
quotes character is included in a string already delimited by quotes
characters.

Ken Sheridan
Stafford, England
 

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