View Single Post
  #3  
Old June 4th, 2010, 11:38 AM posted to microsoft.public.access.reports
JOSELUIS via AccessMonster.com
external usenet poster
 
Posts: 26
Default filrter several reports

Thank you very much.

Allen Browne wrote:
Yes: you can use one form to filter several reports.

You need a control where the user selects which report they want. That could
be a option group, or a combo or list box. Use the AfterUpdate event of that
control to show the filter boxes that apply to that report and hide the
boxes that don't apply.

Then in the Click event of the command button that actually opens the
report, you build the filter string from the controls that are Visible and
Not Null, and finally OpenReport with that WhereCondition.

The example below assumes an option group where each report is one of the
buttons. In the AfterUpdate of the option group (named grpReport), you call
it like this so that the combo for filtering on a client (cblClientID) is
shown if the chose option button optJob or optClient or optClientList:

Dim bShow As Boolean
bShow = GroupMatchesButtons(Me.grpReport, Me.optJob, Me.optClient,
Me.optClientList)
With Me.cboClientID
If .Visible bShow Then
.Visible = bShow
End If
End With

Here's the function:

Private Function GroupMatchesButtons(grp As OptionGroup, ParamArray
aoptButtons()) As Boolean
On Error GoTo Err_Handler
'Purpose: Return True if the option group value matches on one of the
option buttons named in the array.
Dim i As Integer

For i = LBound(aoptButtons) To UBound(aoptButtons)
If aoptButtons(i).OptionValue = grp.Value Then
GroupMatchesButtons = True
Exit For
End If
Next

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod &
".MatchesOptionButtons")
Resume Exit_Handler
End Function

HTH
I create an unbound form to filter a report and i paste the following code
in

[quoted text clipped - 62 lines]

End Sub


--
Message posted via http://www.accessmonster.com