Hi Gerry.
Gerry:
I run the report directly from a portal form with a button using DoCmd.OpenReport "RP_Annual_Report", acViewReport.
I'm guessing that meant Form? No idea what portal is supposed to represent in this but I imagine the important part is that it's run from a Form. After running :
- DoCmd.OpenReport "RP_Annual_Report", acViewReport
you should run the code :
- DoCmd.OutputTo acOutputReport, "RP_Annual_Report", AcFormatPDF, FileName
Gerry:
The report has got a form inside it to accept parameters. When I try running it directly from the portal, it generates a report without any data in it.
Well, that sounds like another problem Gerry. It's very hard to know exactly what the problem is though, unless you can describe it a little better. Are you trying to say that it has a Sub-Form within the Report and that the Report uses references to that Sub-Form to determine what it should include? Sounds like a mess if I'm brutally honest (One of my failings. I often AM brutally honest - but I mean it well).
Let's make it simple. Information that determines how you build up the information in a Report should be determined before you ever get to the point of opening it. I prefer to get that information and build a filter for the Report in code that is then used to open the Report with, as a
WhereCondition parameter. Some people prefer an existing string that has links to the Controls on a Form and to hope that the particular Form is available whenever the Report is run. I find my way gives more reliable results as there are fewer things that can go wrong - obviously assuming you do it right when you do it of course. getting the information from somewhere only after it's been opened though, that seems very awkward.