Change filter on sub-report

T

tedmi

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.
 
T

tedmi

The error I'm getting occurs in the Open event of the subreport. I've come to
the same conclusion as you did: change the sub's recordsource.

Thanks for the response.
 
E

Evi

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
 
E

Evi

Duh, just realized that you were talking about a subreport, not a form. Must
stop answering posts late at night.
Evi
Evi said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top