Changing the type face

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

Is there any way to change the font of ALL the forms in a database without
the need to edit each control individually?
Thanks
Tony
 
Don't know how to do it database-wide, but you can change all the controls on
a given form by going into Design View and goto Edit - Select All then change
the font.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
Tony said:
Is there any way to change the font of ALL the forms in a database without
the need to edit each control individually?


You can write a procedure that opens each form in design
view, sets the FontName property of every control and saves
the form. Here's one that I've used for a similar purpose.
Modify it to suit your needs.

Public Sub ChangeAllControlProps()
Dim dbCur As Database
Dim doc As Document
Dim ctl As Control

On Error GoTo ErrHandler

Set dbCur = CurrentDb

For Each doc In dbCur.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign
For Each ctl In Forms(doc.Name)
ctl.FontName = "Arial"
ctl.FontSize = 10
Next ctl
DoCmd.Close acForm, doc.Name, acSaveYes
Next doc

For Each doc In dbCur.Containers("Reports").Documents
DoCmd.OpenReport doc.Name, acDesign
For Each ctl In Reports(doc.Name)
ctl.FontName = "Arial"
ctl.FontSize = 10
Next ctl
DoCmd.Close acReport, doc.Name, acSaveYes
Next doc

ExitHere:
Set dbCur = Nothing
Exit Sub

ErrHandler:
Select Case Err.number
Case 438 'Property does not exist
Resume Next
Case Else
MsgBox Err.number & " - " & Err.Description
Resume ExitHere
End Select
End Sub
 
Thanks Marsh. Having created the procedure, presumably as a module, how do I
then run it when it isn't part of a procedure in a form? VBA is not my
strong point, but I'm learning!
Thanks
Tony
 
Sorry Marsh found out how, just clicked on RUN, pretty obvious really!
worked fine.
Thanks
 
To globally change the label color I've used this
For Each lbl In Forms(doc.Name)
lbl.ForeColor = 16711680
Next lbl
But get error 13 Type Mismatch
What am I doing wrong, it worked with ctl?
Thanks
Tony
Tony Williams said:
Sorry Marsh how do I reference the control label?
Thanks
Tony
 
Not all controls have a ForeColor property. Try:

For Each lbl In Forms(doc.Name)
If TypeOf lbl Is Label Then
lbl.ForeColor = 16711680
End If
Next lbl


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Tony Williams said:
To globally change the label color I've used this
For Each lbl In Forms(doc.Name)
lbl.ForeColor = 16711680
Next lbl
But get error 13 Type Mismatch
What am I doing wrong, it worked with ctl?
Thanks
Tony
 
Tony said:
Thanks Marsh. Having created the procedure, presumably as a module, how do I
then run it when it isn't part of a procedure in a form?


I normally call my utility procedures from the Immediate
window (Ctrl+G), but you can use the Run menu for procedures
with no arguments.
 
Should not be a reason to do that because the code tries to
set the property for every control that has the property.
 
Thanks Douglas still get same error message?
Tony
Douglas J. Steele said:
Not all controls have a ForeColor property. Try:

For Each lbl In Forms(doc.Name)
If TypeOf lbl Is Label Then
lbl.ForeColor = 16711680
End If
Next lbl
 
Sorry what if I wanted to change just the label colours?
Tony
Marshall Barton said:
Should not be a reason to do that because the code tries to
set the property for every control that has the property.
--
Marsh
MVP [MS Access]


Tony said:
Sorry Marsh how do I reference the control label?
 
See whether

For Each lbl In Forms(doc.Name).Controls

is any better

If not, how have you declared lbl? Even if all you want is labels, you must
still use

Dim lbl As Control
 
Thanks Douglas I'd declared lbl as Label not as Control Worked fine when I
changed that.
Thanks again
Tony
 
If you want to do different things for different kinds of
controls, then use this kind of logic:

For Each ctl In Forms(doc.Name)
ctl.FontName = "Arial"
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.FontSize = 10
ctl.FontBold = True
ctl.BackColor = vbWhite
Case acLabel
ctl.FontSize = 8
ctl.BackColor = RGB(255,220,220) 'pink ;-)
End Select
Next ctl
 
Thanks Marsh
Tony
Marshall Barton said:
If you want to do different things for different kinds of
controls, then use this kind of logic:

For Each ctl In Forms(doc.Name)
ctl.FontName = "Arial"
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.FontSize = 10
ctl.FontBold = True
ctl.BackColor = vbWhite
Case acLabel
ctl.FontSize = 8
ctl.BackColor = RGB(255,220,220) 'pink ;-)
End Select
Next ctl
--
Marsh
MVP [MS Access]


Tony said:
Sorry what if I wanted to change just the label colours?
 
Back
Top