Wednesday, January 6, 2010

Macro or VB code to automate renaming of caption title in microsoft access reports?

I'm trying to rename the captions on reports in Microsoft Access 2003. I need the caption name to match the report name. Is there a way to automate this in VB or with a macro that would set the caption name equal to the report name?





The only other option i have is to open each report in design view and manually rename the caption. I have about 130+ reports to fix so this would take a while.





any help is appreciated.Macro or VB code to automate renaming of caption title in microsoft access reports?
Yes. Put this code in the OnOpen event of the reports:





Me.Caption = Me.Name





You're still going to have to do this for each report, but it should be quicker than re-typing each caption, since you can copy/paste this line of code. You can use the MS VB Editor to move quickly to each report and its Report/Open event.





If the reports do not already have a coded OnOpen procedure, simply paste the entire procedure into their report modules:





*************************





Private Sub Report_Open(Cancel As Integer)





Me.Caption = Me.Name





End Sub





************************


.

No comments:

Post a Comment