Filter preview report code

Emery

Registered User.
Local time
Today, 12:51
Joined
Jul 23, 2008
Messages
15
Hi guys. I have this code for a button, that lets me filter records by selection, then preview a report on the filtered records:

Private Sub Preview_Rpt1_Click()
DoCmd.OpenReport "rpt1", acPreview, , IIf(Me.FilterOn = True, Me.Filter, "")
End Sub


It works fine, but I need to do it again for a different report. So I created another button on a new tabbed page in the same form, and attached the same code to this button. The code for this button looks like this:

Private Sub Preview_Rpt2_Click()
DoCmd.OpenReport "rpt2", acPreview, , IIf(Me.FilterOn = True, Me.Filter, "")
End Sub


Note that the only change is the name of the report, it is now "Rpt2" instead of "Rpt1".

This new button works, but unlike the first button, it asks for a value for the filtered field. The original button just plugs in the value, whereas the second button won't do that. Also, even if you manually enter a value when it asks for one, it doesn't honor the filter.

Any idea why this code works for one button, but not another? Do I need to add something more to the codes to differentiate them?

thanks.
 
To start with....Ensure that the FilterON property for rpt2 is set to Yes.

.
 

Users who are viewing this thread

Back
Top Bottom