Referencing a Subform

mrssevans

Registered User.
Local time
Today, 00:11
Joined
Nov 15, 2001
Messages
190
Referencing a Subreport

I have searched through the forums, but have not found an instance of this yet. I apologize if i overlooked something.
I have a very complicated report which is a main report that is unbound and 3 subreports in the detail section of the unbound main report. I am getting all the correct information in my subreports, but I need to reference to one of the subreports from one of the other subreports. Here is what I was trying...
=(IIf([Reports]![Cattle Inventory Position Summary]![Cattle Inventory Positions].[Report]![Type]=[Type],[Reports]![Cattle Inventory Position Summary]![Cattle Inventory Positions].[Report]![Month1],0))

Basically what would happen is I would get a 0. The subs are grouped by FY and Type so what I was trying to do is if record=type then if record=feedyard then month1. When that didn't work I broke it down to what I displayed above. Any ideas would be appreciated.
 
Last edited:
I am a little confused. Are you running this code from one of the sub reports or from a control on the main form?

Sam
 
Sorry, I was unclear

From a subreport I have a text box with the mentioned iif statement. I don't get an error, but it doesn't find the information I am looking for either.
 
Ok, I can at least show you how you need to refer to a control from one subreport to another subreport.

Let us say we have a report named "Main Report"
Let us say we have 2 subreports called "subreport1" and "subreport2"

And let us say we have a text control on subreport1 called "GetMe"
And let us say we have a text control on subreport2 called "GoGetIt"

The proper syntax to enter into "GoGetit" would be:

=Reports![Main Report]!subreport1!GetMe

Hope this helps

I have attached an example. It also includes an example of subforms.
 

Attachments

Thank you for the reply and the example. I can see how that would work and I have actually used that option before, however this situation seems to be a little more complicated for some reason. I would have to somehow use an iif statement because the information needs to match correspond to the location. Something like iif(report!location=location, iif(report!type=type,totalhead))
When I use the correct syntax for this example it doesn't return any information, but I also don't get an error. Any other ideas?
 
I would suggest you zip up your access database and let someone give it a go. If you are concerned about security then delete and data you do not want others to see.

Sam
 
Thank you for trying to help. The database is too complex with linked tables, etc. I might try to setup a similiar one that isn't linked and post it.

Thanks again
 
No, no data without the iif's either. There are no errors, but no data.
 

Users who are viewing this thread

Back
Top Bottom