Full Version: Report output based on search results
UtterAccess Forums > Microsoft® Access > Access Forms
sokolln
I have seen the other posts in the same vein as this question but I've been unable to solve my problem.
I have a search function and when the search is executed I would like to view reports based solely on the search results.
The code I am using is as follows:
CODE
Dim stDocName As String
stDocName = "Organizational Profile"
If Me.FilterOn And Len(Me.Filter & "") > 0 Then
DoCmd.OpenReport stDocName, acViewPreview, WhereCondition:=Me.Filter
Else
DoCmd.OpenReport stDocName, acViewPreview
End If
Exit_Preview_report_Click:
Exit Sub
End Sub

This works fine if I "filter by form" but it does not work with my search function. When I run the search, the total record number decreases but the word "(filtered)" does not appear after it.
This is the filtering code for my search:
CODE
         Forms![Master Form by Ult Parent].RecordSource = "select * from [Master Form by Ult Parent Query] where " & GCriteria
        Forms![Master Form by Ult Parent].Caption = LCaption
        Me.FilterOn = True

Any ideas?
dashiellx2000
The reason you are not seeing the worked "(filtered)" is because you are not actually filtering the form, you are in fact changing it's recordsource.
If you want for filter it, you can do:
CODE
Dim varFilter as Variant
Me.Filter = varFilter
Me.FilterOn = True

HTH.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.