remembering strWhere

  • Thread starter Nick Del Vecchio
  • Start date
N

Nick Del Vecchio

I have a form that has 3 quick filter command buttons. After the user
hits the filter buttons, I'd like the user to be able to print preview
with the filters they selected. Right now, it is working by making 3
additional print preview buttons with a code like this,

DoCmd.OpenReport "rptPrintPreview", acViewPreview, , strWhere

Rather than having 3 extra buttons, I'd like for Access to remember
the strWhere condition so that I can have just one button for print
preview.

Is there a way to temporarily store the strWhere filter so that it is
available again?
 
B

Bob Quintal

m:
I have a form that has 3 quick filter command buttons. After the
user hits the filter buttons, I'd like the user to be able to
print preview with the filters they selected. Right now, it is
working by making 3 additional print preview buttons with a code
like this,

DoCmd.OpenReport "rptPrintPreview", acViewPreview, , strWhere

Rather than having 3 extra buttons, I'd like for Access to
remember the strWhere condition so that I can have just one button
for print preview.

Is there a way to temporarily store the strWhere filter so that it
is available again?

strWhere is a variable. Variables are scoped to the procedure in
which they are defined, the module in which they are defined or to
the application.

Read up on "Understanding Scope and Visibility" in help, then change
yours as applicable.

Since I cannot see your code, I can't offer anything more specific.
 
A

Allen Browne

You could declare the variable in the General Declarations section of the
form's module (at the top, with the Option statements), so it retains its
previous values while the form is open. You'll have to initialize it back to
a zero-length string when you need to clear it of course.

But you may not need to do that. You may be able to simply apply the form's
filter to the report:
Dim strFilter As String
If Me.FilterOn Then strFilter = Me.Filter
DoCmd.OpenReport "rptPrintPreview", acViewPreview, , strFilter
 
N

Nick Del Vecchio

Thanks Allen. That is exactly what I was looking for.
I tried it and it is working very well.
Awesome!!

Thanks again...

Nick
 

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