Global property change

T

Tony Williams

Can someone give me the VBA code to globally change the back style for all my
controls on reports to be transparent?
Thanks
Tony
 
F

fredg

Can someone give me the VBA code to globally change the back style for all my
controls on reports to be transparent?
Thanks
Tony

The following should change all label and text box controls backstyle
to transparent. If you are using any other type of controls that have
a BackStyle, add that type to the If TypeOf ctl Is line of code using
an Or as operator.

Public Sub ChangeControlProperty()
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim doc As Document
Set db = CurrentDb
Dim ctl As Control

For Each doc In db.Containers("Reports").Documents
DoCmd.OpenReport doc.Name, acViewDesign, , , , acHidden
For Each ctl In Reports(doc.Name)
If TypeOf ctl Is TextBox Or TypeOf ctl Is Label Then
ctl.BackStyle = 0
End If
Next
DoCmd.Close acReport, doc.Name, acSaveYes
Next

Exit_Sub:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " " & Err.Description
Resume Next

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