Global setting for text size.

snicker

Registered User.
Local time
Today, 16:50
Joined
Aug 8, 2003
Messages
91
I'm trying to make it easy for a user to resize text throught out a database. This is the code I'm using minus the error checking
Code:
Function SetTextSize(FormName As Form)

Dim CComp As New CComputer
Dim ctl As Control
    With CComp
        filestring = .UserName
    End With
fUserName = filestring
UsersSettingSize = DLookup("TextSize", "tblOptions", "UserName = '" & fUserName & "'")

    For Each ctl In Forms(FormName.Name)
    Select Case ctl.ControlType
    Case acTextBox
            ctl.FontSize = UsersSettingSize
        Case acComboBox
            ctl.FontSize = UsersSettingSize
        Case acListBox
            ctl.FontSize = UsersSettingSize
        Case acLabel
            ctl.FontSize = UsersSettingSize
        Case Else
            'do nothing for the other controls
    End Select
    Next ctl

End Function
And I'm calling this code in the onOpen event from a form
Code:
SetTextSize(Me)
This works great for most forms, but itdoesn't work on forms with subforms. I've tried all kinds of stuff to get this to work. Can some lead me in the right direction?
 
Code:
Function SetTextSize(FormName As Object)
Dim UsersSettingSize As Long
Dim ctl As Control
Dim subctl As Control
Dim subfrm As SubForm
UsersSettingSize = 20
    For Each ctl In Forms(FormName.Name)
    Select Case ctl.ControlType
    Case acTextBox
            ctl.FontSize = UsersSettingSize
    Case acComboBox
            ctl.FontSize = UsersSettingSize
    Case acListBox
            ctl.FontSize = UsersSettingSize
    Case acLabel
            ctl.FontSize = UsersSettingSize
    'Case subform
    Case acSubform
            'Set ctl to subform object
            Set subfrm = ctl
            For Each subctl In subfrm.Controls
            'For each ctl on the subform
                Select Case subctl.ControlType
                       Case acTextBox
                            subctl.FontSize = UsersSettingSize
                        Case acComboBox
                            subctl.FontSize = UsersSettingSize
                        Case acListBox
                            subctl.FontSize = UsersSettingSize
                        Case acLabel
                            subctl.FontSize = UsersSettingSize
                        Case acSubform
                            'no double instance
                             Exit Function
                       Case Else
                       'do nothing for the other controls
                End Select
            Next subctl
        Case Else
            'do nothing for the other controls
    End Select
    Next ctl

End Function
I have amended your code to include subform controls (of one instance). A subform is not a form it is a control. Controls only holds the controls on the current form not the controls on the subforms. So in get those controls you must reference the subform object’s controls. Get it?
 
thx alot. Works like a charm.
 

Users who are viewing this thread

Back
Top Bottom