Filter not working in sub report

P

PayeDoc

Hello All

I have a report that has the following onOpen event:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = "([nhsp ers]<>0 Or [nhsp ees]<>0 Or [added yrs pen]<>0) and
[nhsp membership]=2"
Me.FilterOn = True
End Sub

The report opens fine when opened directly, but when I use it as a sub
report I get the message:

Runtime error 2101 The setting you entered isn't valid fro this property.

.... and when I click Debug I am taken to the Me.Filter line in the above
onOpen event.
Why is this happening, and what should I do?

Hope someone can help.
Thanks in advance
Les
 
A

Allen Browne

The timing of the events means that this approach doesn't work. You need to
find another way to filter the subreport instead of Report_Open.

If the filter never changes, just make a query and type the criteria in. Use
the query as the RecordSource of the report.

If you need the user to select the filter, create the query so it reads the
values from the form. For example, you might set the Criteria row under one
of the fields to:
<> [Forms].[Form1].[Text0]
 

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