Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering Reports 1

Status
Not open for further replies.

Bensta

Programmer
Jul 21, 2003
122
US
I am trying to filter a report based on values entered by users. The actual creterias are selected from multiple group options, text box, and multiple listboxes. I am kind of new to access. Can anyone be kind to help me with that or direct me to a similar example. I would truly appreciate it.
Thank you
 
Hi, you might find this useful. It prints the results from a filtered form (frmPrintAnything). It is place in the reports On Open event.

Private Sub Report_Open(Cancel As Integer)

Dim frm As Form

If (CurrentProject.AllForms("frmPrintAnything").IsLoaded) Then
Set frm = Forms("frmPrintAnything")

Me.RecordSource = frm.RecordSource
If (frm.FilterOn) Then
Me.Filter = frm.Filter
Me.FilterOn = True
End If

If (frm.OrderByOn) Then
Me.OrderBy = frm.OrderBy
Me.OrderByOn = True
End If
End If
End Sub
 
Thank you so much for you replay.
I did put the module on the open event of the report, but nothing shows up on the reports. I get #name, error on the report. I don;t know what I am doing wrong.
Thank you
 
Hi, the report is looking for a form named "frmPrintAnything". The report recordsource is the filtered form, which is defined on the Open Event of the report.

The "frmPrintanything" lists all the records in the table - it has a recordsource. There are filters built into the form to filter down to the records the user wishes to print. The report then uses the results of the the filtered form as the recordsource. Kind of a WYSIWYG way of doing things.

So, this may or may not apply to your needs since you mention several different controls used in filtering.
If your form has no recordsource this will not work. If it does, type in your form's name in place of 'printanything' and you should get something.

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top