DoCmd.OpenReport not opening subreport

  • Thread starter Thread starter prodeji
  • Start date Start date
P

prodeji

Hi all

I have a report that runs on a query (duh) :).

I set up a combo box on a form to select these parameters.

The code of the "OK" button includes a DoCmd.OpenReport so it'll go
straight to the report rather than runnin the query and then including
an event trigger to run the report once the query has been run (or
something like that).

However, when the report is run, the (2) subreports give a "#Name"
error.

I gather so far that this basically means Access can't find the object
it generates this error for.

When I did it the tacky way originally (run query then some trigger to
run the report) the subreports displayed fine.

How can I run the report straight from the OK button's code
(DoCmd.OpenReport) without generating the "#Name" errors?

Thanks for any help

prodeji
 
I've never had a similar problem. You don't run the Query and _then_ use it
in a Report, in any case -- the Query is the RecordSource of the Report.

My guess is that the LinkMasterFields and LinkChildFields properties of the
Subreport Control are not correct.

Larry Linson
Microsoft Access MVP
 
Thanks Larry,

What actually hapenned was I was trying to run the wrong report - I
referenced a previous iteration of the report in the VBA code, you
know... rptName, rptName2 type of deal... I referenced rptName instead
of rptName2, which is the current working version.

When I realized what I had done, I yanked the topic, I was so
embarrassed.

Guess I didn't yank it quick enough lol.

Thanks for replying, anyway.

:)
 
Back
Top