Changing a subreport source object

Gkirkup

Registered User.
Local time
Today, 11:30
Joined
Mar 6, 2007
Messages
628
I have a report with a subreport. I want to change the subreport's source object based on a couple of criteria, like this:

If Right([DTACTIONFAIL], 6) <> "credit" And Right([DTACTIONFAIL], 11) <> "Replacement" Then
Me.DTScanFAIL.SourceObject = Form.DTSCanEmpty
End If

I tried this on both the ON FORMAT and ON PRINT areas of the parent report's Detail section. I get 'Object required'. Should I change the subreport's source object somewhere else?

Robert
 
I've never tried to change source objects in the detail, but the correct syntax would be:

Me.DTScanFAIL.SourceObject = "DTSCanEmpty"

Typically you'd also have an "Else" clause to set it to the other source object. Again, never tried this type of thing in the detail format event, so no guarantees of it working at all.
 
Paul: Where else could I set the subreport source object?

Robert
 
Have you tried it? It may work, I've just never tried, and it just seems dicey to have a different source object in different records on the same report. I've set the source object in forms where I wanted to change it for whatever reason. If it works, the detail format event would be the place to set it. Try it, what could go wrong? :p
 
Actually I just found this in VBA help:

You can't set or change the SourceObject property in the Open or Format events of a report.

So if you're looking to have a different source in each record, I suspect you'll hit a brick wall. If so, a workaround might be to have 2 subreports, and toggle their visibility in the format event.
 
OK, that worked! All I was trying to do was to turn off the subreport based on two parameters. Making it not visible is easier.

Robert
 
Glad it worked for you!
 

Users who are viewing this thread

Back
Top Bottom