Access Calendar control Setting fonts.

J

JAmateur

Im using Access 2003, and have a calendar control (ctrlCal) on my form. I
would like to set, via VBA, the Title Font, Grid Font and Day Font in the
control. How is this done?

Thanks
 
J

Jeff Conrad

in message:
Im using Access 2003, and have a calendar control (ctrlCal) on my form. I
would like to set, via VBA, the Title Font, Grid Font and Day Font in the
control. How is this done?

This worked for me:

Private Sub cmdChangeFonts_Click()
Me.ctrlCal.TitleFont.Name = "Times New Roman"
Me.ctrlCal.DayFont.Name = "Times New Roman"
Me.ctrlCal.GridFont.Name = "Times New Roman"
End Sub

Hope that helps,
 
J

Jeff Conrad

Another thought occurred to me on this.
You could give the end-user their choice of fonts to use on
the calendar.

1. Create an unbound combo box and manually feed in the font names
you wish to present them (or create a table of font names). Name the
combo box cboPickFonts and set to Limit To List.

2. In the AfterUpdate event of the combo box put this code in:

'*********Code Start************
Private Sub cboPickFonts_AfterUpdate()
On Error GoTo ErrorPoint

Dim ctrl As Control
Dim strFont As String

Set ctrl = Me.ctrlCal
strFont = Me.cboPickFonts

With ctrl
.TitleFont.Name = strFont
.DayFont.Name = strFont
.GridFont.Name = strFont
End With

ExitPoint:
' Cleanup Code
On Error Resume Next
Set ctrl = Nothing
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
'*********Code End************

After they make a selection from the combo box, the fonts
on the calendar will change accordingly.

Just an idea for you,
--
Jeff Conrad
Access Junkie
Bend, Oregon

in message:
 
J

JAmateur

Thanks Jeff
Jim

Jeff Conrad said:
Another thought occurred to me on this.
You could give the end-user their choice of fonts to use on
the calendar.

1. Create an unbound combo box and manually feed in the font names
you wish to present them (or create a table of font names). Name the
combo box cboPickFonts and set to Limit To List.

2. In the AfterUpdate event of the combo box put this code in:

'*********Code Start************
Private Sub cboPickFonts_AfterUpdate()
On Error GoTo ErrorPoint

Dim ctrl As Control
Dim strFont As String

Set ctrl = Me.ctrlCal
strFont = Me.cboPickFonts

With ctrl
.TitleFont.Name = strFont
.DayFont.Name = strFont
.GridFont.Name = strFont
End With

ExitPoint:
' Cleanup Code
On Error Resume Next
Set ctrl = Nothing
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
'*********Code End************

After they make a selection from the combo box, the fonts
on the calendar will change accordingly.

Just an idea for you,
--
Jeff Conrad
Access Junkie
Bend, Oregon

in message:
 
Top