In the lastest versions of Access you can open it hidden:
DoCmd.OpenReport "Report1", acViewPreview, WindowMode:=acHidden
Closing it programmatically is:
DoCmd.Close acReport "Report1"
The real problem with that approach is that Access only fires the events of
the sections for the pages it has to format. That means it needs to walk
through all the pages to generate the TOC. I haven't tried this, but you
might be able to output the report to the nul: device as a way of forcing it
to walk through its pages and generate the contents data:
DoCmd.OutputTo acOutputReport, "Report1", acformatTXT, "nul:"
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Vayse" <va***@deadspam.comwrote in message
news:Zn*******************@news.indigo.ie...
Thanks. I'm using an ADP, so I can't use temp tables, but I'll be change
the code to use an array easily enough.
The kb method requires the report to open to generate the TOC. Is is
possible that I could open the report once, close it through code, then re
open. When I re open I would have the information required for the TOC. Is
there a way to open the report 'invisibly' the first time? Or even a way
of closing it?
Thanks
Vayse
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
>See:
How to Create a Table of Contents or Index for a Report
at:
http://support.microsoft.com/kb/210269/en-us
"Vayse" <va***@deadspam.comwrote in message
news:zD*******************@news.indigo.ie...
>>>I have a report which has several sub reports. Each sub report starts on
its own page, and may be 2 or 3 pages long.
I'd like to create an index on the first page of the main report.
Something like:
Clients..............p1
Sales................p3
Salesmen.........p4
I'm not sure how I would do this, as I don't know before hand what page
a sub report will start on.
Is this even possible?
Thanks
Vayse