remembering strWhere

  • Thread starter Thread starter Nick Del Vecchio
  • Start date 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?
 
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.
 
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
 
Thanks Allen. That is exactly what I was looking for.
I tried it and it is working very well.
Awesome!!

Thanks again...

Nick
 
Back
Top