Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop though reports and insert a new object to it

Status
Not open for further replies.

neemi

Programmer
May 14, 2002
519
GB
access 2002

I have about 400 reports in my database and I need to print samples of them off. However can loop through them and print them out but as there is so many I need to some how add a new object to the top of the report including the object name.

Is this possible to do programatically in vba?

Advice appreciated as this is an urgent task.

Cheers,
Neemi
 
You can create code to loop through each report and
- open the report in design view
- add a control
- close and save the report

To display the report name in a text box, set the control source to:
=[Name]

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
This is what i've done in the past.

Dim rpt As AccessObject

Dim ctlNewLine As Control

Dim obj As Control
For Each rpt In CurrentProject.AllReports

Set obj = CreateReportControl(rpt.Name, actextbox, [section], , "",
,[top], [width],[height])

obj.controlsource=[name]
DoCmd.Close acReport, rpt.Name, acSaveYes

End If
Next rpt​
 
Thanks for the response GavinP.

After a bit of seraching around I found what I needed. The command "CreateReportControl" as you suggested, and done more or less what you have wrote but used the control to amend the name of the textbox, font size etc.

Thanks again.
Cheers,
Neemi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top