save filter and use same criteria for all queries in a macro

S

S.Matthew

The Macro I used has several quries and a report. The queries are ususally
parameter query i use to filter data. The report is also based on a
parameter query. all these queries has the same 2 parameter for example
Enter Vessel Code
Enter Owner

When I run the macro i have to type in the same parameters 4 times, is there
a way to save this filter, and use it for all the query in that particular
macro. I cannot use a condition since the vessel code could be different
the next time i run the macro. I am not sure about applyfilter option

Any help is appreciated
Thanks in advance
S.Matthew
 
S

Steve Schapel

S.Matthew,

I reckon the best way to do this is to have a form which will be opwen
at the time that you report is printed, with a couple of unbound
textboxes where you enter the Vessel Code and the Owner, and then
instead of the parameter prompts in the query, replace them with
refernces to the form controls using syntax such as...
[Forms]![NameOfYourForm]![NameOfTextbox]
 
S

S.Matthew

Hello Steve
When a command button is clicked that is when this macro is executed. I am
opening a make table query which prompts me for the Vessel code and Owner.
the second query in the macro is a cross tab query which just displays the
results and then an open report action which also promts me to enter the
vessel code and Owner. I was wondering if it would be possible for me to
just enter the vessel code and owner once and that value retains for the rest
of the queries and reports in the macro.
S.Matthew
S.Matthew,

I reckon the best way to do this is to have a form which will be opwen
at the time that you report is printed, with a couple of unbound
textboxes where you enter the Vessel Code and the Owner, and then
instead of the parameter prompts in the query, replace them with
refernces to the form controls using syntax such as...
[Forms]![NameOfYourForm]![NameOfTextbox]

--
Steve Schapel, Microsoft Access MVP

S.Matthew said:
The Macro I used has several quries and a report. The queries are ususally
parameter query i use to filter data. The report is also based on a
parameter query. all these queries has the same 2 parameter for example
Enter Vessel Code
Enter Owner

When I run the macro i have to type in the same parameters 4 times, is there
a way to save this filter, and use it for all the query in that particular
macro. I cannot use a condition since the vessel code could be different
the next time i run the macro. I am not sure about applyfilter option

Any help is appreciated
Thanks in advance
S.Matthew
 
S

Steve Schapel

S.Matthew

I believe I understood the question the first time. My suggestion is to
scrap the idea of a Parameter Query etc. My suggestion is to put two
unbound textboxes on the same form where the command button is, enter
the Vessel Code and Owner criteria into these textboxes, and refer to
these textboxes where needed. This means you only have to enter the
Vessel Code and Owner one time, and these values will be used for all
the queries and reports activated by the macro. There are other
advantages of this approach as well.
 
S

S.Matthew

Thanks Steve it works fine

Steve Schapel said:
S.Matthew

I believe I understood the question the first time. My suggestion is to
scrap the idea of a Parameter Query etc. My suggestion is to put two
unbound textboxes on the same form where the command button is, enter
the Vessel Code and Owner criteria into these textboxes, and refer to
these textboxes where needed. This means you only have to enter the
Vessel Code and Owner one time, and these values will be used for all
the queries and reports activated by the macro. There are other
advantages of this approach as well.
 

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