After having slogged through creating a table of contents for my access report, I have finally gotten to the point where the code works, and a table of contents is created.
As the instructions from Microsoft state, I need to manually click through the Print Preview until the last page so that the TOC is created. This works.
How can I click through the Access Report using SendKeys?
Here is my code so far... it works perfectly, except that SendKeys does nothing!
'Click through report so that TOC code is executed
Dim rptCurReport As Report
Set rptCurReport = Screen.ActiveReport
With rptCurReport
Application.DoCmd.SelectObject acReport, "rptFundSelectionList"
.Visible = True 'switch to false once code is ok
'go through all pages
For i = 1 To .Pages
SendKeys "{PGDN}", True
Next i
'DoCmd.Close acReport, "rptFundSelectionList"
End With
I have managed to finally solve this issue for myself. Here is the code. May it help some other poor soul!