Report Filter (1 Viewer)

PC User

Registered User.
Local time
Yesterday, 22:35
Joined
Jul 28, 2002
Messages
193
I'm trying to develop a filter for a report based on the content of a textbox on the initiating form. The following code in in the report's Activate event and I can't get it to work. Can someone help me?
Code:
Private Sub Report_Activate()

    Filter = Nz((([Facility] Like "*" & Forms!frmMain.Form!txtFacilityName & "*")), "*")
    FilterOn = True

End Sub
 

Laurentech

Registered User.
Local time
Yesterday, 23:35
Joined
Nov 7, 2005
Messages
107
Try this:

me.filter = "Facility Like * " & nz(forms!frmMain!txtFacilityName,"") & "*"
me.filteron=true

I always use code like this in the Open event of the report. Never tried Activate.

Larry
 

Laurentech

Registered User.
Local time
Yesterday, 23:35
Joined
Nov 7, 2005
Messages
107
Oops - forgot the single quotes:

me.filter = "Facility Like '*" & nz(forms!frmMain!txtFacilityName,"") & "*'"
me.filteron=true

The last bit after the * is a single quote ' followed by a double quote ".

I think that should work for you.

Larry
 

Users who are viewing this thread

Top Bottom