Hoew do I reference a subreport field in the main report?

J

JohnB

Hi

I did search for this and tried using the solution given in one post but it
doesn't work. Perhaps I misunderstand.

In a reports 'On Format' Event, I want to check for the value in a field
called txtStartYear that's in a subreport called frmsubReport3.

I read that you could do this using something like:

If subreport.Report.txtStartYear = 28 Then

but that doesn't work. It seems curious that this solution doesn't mention
the subreport name, so perhaps that's where I'm going wrong.

How should the code read?

Thanks.
 
E

Evi

Hi John

You'll kick yourself when I tell you.
You're supposed to place the name of your own subreport into the bit that
says Subreport. So in your case, the reference would read.

frmsubReport3.Report.txtStartYear


But just check first that your subreport really does have the name you think
it has.

To do this, click on the Subreport in the Main Reports, Click on the
Properties button, click on Other and look what it says next to Name.
It may not be the same as the name you can see in your database window.

If it isn't, for future convenience, change the name in Properties to the
name in your database window.

Evi
 
J

JohnB

Thanks Evi.

Yes, consider the kick self administered. That's all clear now.

Thanks also for the hint about clearly identifying the subreport name - I've
been caught out with that sort of thing before, so I'll be sure to check.

Thanks for your prompt replies.
 

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