Here's the code which I use to filter my subform to the current month (I
have a calculated field called Mnth in the subform.. I use the On Open Event
of the *Main* form
Private Sub Form_Open(Cancel As Integer)
Dim MyMonth As Integer
Dim MySub As Control
Dim frm As Form
'maximise form
DoCmd.Maximize
'filter form to show current month
MyMonth = Month(Date)
Me.cboMonth = MyMonth
Set MySub = Me.FrmJobsExpensesV2Sub
'the name of my subform control
MySub.SetFocus
'MySub.Form.FilterOn = False
'Remove previous Filters
MySub.Form.Filter = "[Mnth] =" & MyMonth
MySub.Form.FilterOn = True
Set MySub = Nothing
DoCmd.GoToControl "FrmJobsExpensesV2Sub"
DoCmd.GoToRecord , , acNewRec
End Sub
Evi
tedmi said:
I can't change the filter string of a sub-report in its Open event.
Attempting to set either Me.Filter or Me.FilterOn produces the message:
The setting you entered isn't valid for this property
Thanks for any help.