Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm using MS Access 2010.

I have a form with a number of fields of various types (number, text, lookup, checkbox).

Users can right click on any field to filter the form.

Then I have a button that generates a report based on this filtered data:

Private Sub Filter_and_Report_Click()
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If Me.FilterOn Then strWhere = Me.Filter
DoCmd.OpenReport "WallsRpt", acViewPreview, , strWhere
End Sub

My question is how to list the fields that were filtered in the report (probably in the header/footer).

share|improve this question

1 Answer 1

The Filter condition is in Me.Filter: you use it above.

You'd have to parse this, but you must have set it previously to be able to apply it. Ignoring SQL Injection risk (I just got this off the interwebs), you know in this snippet you are filtering on ProductCatID

Me.Filter = "ProductCatID = """ & Me.cboShowCat & """"
Me.FilterOn = True

You can set a new variable/property (eg Me.Tag) for use in the Header/Footer

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.