Find and Replace Text in Labels on Reports and Forms

T

tcb

I would like code to find and replace text in labels on reports and
forms. Where is this stored? How do you get at it?

I know there are a few third party programs like:

Rick's Find and Replace
ReplaceWiz
Speed Ferret

But I would rather code it myself if this is possible.

Otherwise, recommendations on the above products?
 
B

Brendan Reynolds

As a demonstration to get you started, the following code just loops through
the form labels and lists their names and captions in the Immediate window.
To do the same thing for reports, just substitute 'AllReports' for
'AllForms', 'OpenReport' for 'OpenForm', 'Reports' for 'Forms', and 'rpt'
for 'frm'.

I use and am very satisfied with Find and Replace. I can't tell you how it
compares with any of the others, though, as I haven't used them.

Public Sub LabelCaptions()

Dim aob As AccessObject
Dim frm As Form
Dim rpt As Report
Dim ctl As Control

For Each aob In CurrentProject.AllForms
DoCmd.OpenForm aob.Name, acDesign, , , , acHidden
For Each ctl In Forms(aob.Name)
If ctl.ControlType = acLabel Then
Debug.Print ctl.Name, ctl.Caption
End If
Next ctl
Next aob

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top