Change the control labels to user friendly labels

G

Guest

Hello everyone

I have labels on my report that are not aesthetically appealing. for
instance a lable may read "Create_Date", but I would like it to read "Create
Date". There are about 60 lables on the report that contains an "_"
(underscore). There could be multiple underscores or none at all. How can I
progammatcally elimate underscore or replace the underscore with a " "
(space) on my report. I think I would have to create a function on the
onload() or something similar.

Thanks In Advance
kw_uh97
 
R

Rick B

Just go into design view and change the labels to whatever you want. No
need to build code to do this. Just fix it once, and be done.

Personally, I modify most labels when I build a report.

Rick B
 
F

fredg

Hello everyone

I have labels on my report that are not aesthetically appealing. for
instance a lable may read "Create_Date", but I would like it to read "Create
Date". There are about 60 lables on the report that contains an "_"
(underscore). There could be multiple underscores or none at all. How can I
progammatcally elimate underscore or replace the underscore with a " "
(space) on my report. I think I would have to create a function on the
onload() or something similar.

Thanks In Advance
kw_uh97

If your version of Access supports the Replace() function
(Access 2000 or newer):
To change all the captions each time you run the report, place the
following in the Report's Open event:

Dim c As Control
For Each c In Controls
If TypeOf c Is Label Then
c.Caption = Replace(c.Caption, "_", " ")
End If
Next

To permanently change all the captions (and save the changes), place
the following in a new module. Run it just once.

Private Sub ChangeCaptions()
DoCmd.OpenReport "ReportName", acViewDesign, , , acHidden

Dim c As Control
For Each c In Reports!ReportName.Controls
If TypeOf c Is Label Then
c.Caption = Replace(c.Caption, "_", " ")
End If
Next

DoCmd.Close acReport, "ReportName", acSaveYes

End Sub
 
G

Guest

Thanks Rick B and fredg that did the trick. I have just started dealing with
code and I am trying to get used to doing a lot of stuff via logic and code.

Thanks
Ken
 

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