Experts stumped?

B

Bill Stanton

I don't believe it... from a previously un-answered
post:

I have not been able to set the filter expression for a sub-report's
RecordSource. As you can see from the code, I attempted
to inherit the RecordSource and its filter properties from the
parent report. The three lines you see commented out did
not work at all. Failing that, I put a global variable
"FltrDonSum" in a general module and set its value in the
OnOpen code of the main report. However, when I attempted
to execute the statement:

Me.Filter = "DOE = " & FltrDonSum

I get a Run-Time error 2101 "The setting you entered isn't
valid for this property". Yet, debug shows the filter to be
exactly what it should be. I hard-coded a value for the
expression to eliminate any possible problems with the
global variable "FltrDonSum", but got the exact same
error.

What am I missing here?

Thanks,
Bill


Option Compare Database
Option Explicit

Private Sub Report_Open(Cancel As Integer)
Static Initialized As Boolean

If Not Initialized Then
'==================================
' Inherit RecordSource and filter from parent report
'==================================
' Me.RecordSource = Me.Parent.RecordSource
' Me.Filter = Me.Parent.Filter
' Me.FilterOn = True

Initialized = True 'Only run this code once

Me.Filter = "DOE = " & FltrDonSum 'Main rpt set this
End If

End Sub
 

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