Source Object in subreport

B

benj

is it possible to change the subreports' source object depending on certain
criteria? I have 32 subreports and instead of making 32 main report I only
want to have 1 main report. This would make future re-formating of the main
report easier.

THANKS!
 
M

Marshall Barton

benj said:
is it possible to change the subreports' source object depending on certain
criteria? I have 32 subreports and instead of making 32 main report I only
want to have 1 main report. This would make future re-formating of the main
report easier.

Yes, you can do that, but only by using code in the report's
Open event.
 
B

benj

i wrote on the open event:
if me.age = "Yes" then
me.subreportNAME = "RF_elisaA"
else
me.subreportNAME = "RF_elisaB"
and so on.....
i know i didnt get it right coz a "run-time error 2427: You entered an
expression that has no value" appears. how should i do it? thanks!
 
M

Marshall Barton

You can not refer to the Value of a control in a report's
Open event because the data has not yet been loaded. (The
value of a bound control can be different on diferent
records, so which value did you think you were using?) You
need to find another way to determine which subreport to
use.

One possibility might be to have the Age value in a control
on the form that initiated the report. In this situation,
you could use something like:

If Forms!theform.txtAge = "Yes" Then
Me.[subreport control name].SourceObject = "RF_elisaA"
Else
Me.[subreport control name].SourceObject = "RF_elisaB"
. . .
 

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