properties of forms

  • Thread starter Thread starter Frank Dulk
  • Start date Start date
Frank,
Borders - yes it can be changed using VBA.
To find the vba help for borders:
Press Ctl + G to open the immediate window
Type borderstyle in the immediate window
Put the cursor in the word borderstyle and press F1
The vba help window opens
It explains about the different border styles and their settings


Colors - forms have a background color
It is on the property dialog for the form >> format tab >> Back Color
To find vba help for colors, in the immediate window type backcolor and
press F1


Jeanette Cunningham -- Melbourne Victoria Australia
 
Here is some sample code that changes properties of controls on forms.
I haven't used this code, but you could adapt it to change borders and
backcolor for forms.

----------------------------
Public Sub ChangeProperties()

Dim Db As Database, doc As Document, ctl As Control
Set Db = CurrentDb
On Error GoTo Err_Handler
For Each doc In Db.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
For Each ctl In Forms(doc.Name)
If TypeOf ctl Is Label Then
ctl.FontName = "Arial"
ctl.FontSize = 7
ElseIf TypeOf ctl is TextBox then
ctl.FontName = "TimesNewRoman"
ctl.FontSize = 10
End If
Next
DoCmd.Close acForm, doc.Name, acSaveYes
Next

Exit_ChangeProperties:
Set Db = Nothing
Exit Sub
Err_Handler:
MsgBox "Error #: " & Err.Number & vbNewLine & Err.Description
Resume Exit_ChangeProperties
End Sub
---------------------------------------------
The above assumes you wish different fonts, etc. for different types
of controls. Add other control types as needed, or combine them into an If..
Or..
ElseIf .. Then statement.

When I need to do this I use a handy utility called Find And Replace by Rick
Fisher.
If you google for Rick Fisher you will find his website and this utility for
purchase.
There are other utilities that do the same thing, FMS Inc has one and I
think there has been a free one mentioned on the access groups - I don't
have its details handy.


Jeanette Cunningham MS Access MVP -- Melbourne Australia
 
Thank you, it helped enough


Jeanette Cunningham said:
Here is some sample code that changes properties of controls on forms.
I haven't used this code, but you could adapt it to change borders and
backcolor for forms.

----------------------------
Public Sub ChangeProperties()

Dim Db As Database, doc As Document, ctl As Control
Set Db = CurrentDb
On Error GoTo Err_Handler
For Each doc In Db.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
For Each ctl In Forms(doc.Name)
If TypeOf ctl Is Label Then
ctl.FontName = "Arial"
ctl.FontSize = 7
ElseIf TypeOf ctl is TextBox then
ctl.FontName = "TimesNewRoman"
ctl.FontSize = 10
End If
Next
DoCmd.Close acForm, doc.Name, acSaveYes
Next

Exit_ChangeProperties:
Set Db = Nothing
Exit Sub
Err_Handler:
MsgBox "Error #: " & Err.Number & vbNewLine & Err.Description
Resume Exit_ChangeProperties
End Sub
---------------------------------------------
The above assumes you wish different fonts, etc. for different types
of controls. Add other control types as needed, or combine them into an
If.. Or..
ElseIf .. Then statement.

When I need to do this I use a handy utility called Find And Replace by
Rick Fisher.
If you google for Rick Fisher you will find his website and this utility
for purchase.
There are other utilities that do the same thing, FMS Inc has one and I
think there has been a free one mentioned on the access groups - I don't
have its details handy.


Jeanette Cunningham MS Access MVP -- Melbourne Australia
 
Back
Top