From: Nick Del Vecchio on
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?
From: Bob Quintal on
Nick Del Vecchio <las.sierras(a)gmail.com> wrote in
news:b81db382-8f05-484c-ab4d-d9b8df804c2a(a)q16g2000yqq.googlegroups.co
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.


--
Bob Quintal

PA is y I've altered my email address.
From: Allen Browne on
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Nick Del Vecchio" <las.sierras(a)gmail.com> wrote in message
news:b81db382-8f05-484c-ab4d-d9b8df804c2a(a)q16g2000yqq.googlegroups.com...
> 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?

From: Nick Del Vecchio on
Thanks Allen. That is exactly what I was looking for.
I tried it and it is working very well.
Awesome!!

Thanks again...

Nick



On Mar 2, 7:18 pm, "Allen Browne" <AllenBro...(a)SeeSig.Invalid> wrote:
> 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
>
> --
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users -http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Nick Del Vecchio" <las.sier...(a)gmail.com> wrote in messagenews:b81db382-8f05-484c-ab4d-d9b8df804c2a(a)q16g2000yqq.googlegroups.com...
>
> > 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?