Question : Loop thru controls in from header

I have one application that is used by many different clients.  Although the database requirements are the same for all of them, they refer to certain fields differently, so I dynamically load the captions of the labels of those fields based on the strored client preferences.  Rather than having the same logic in many forms I call the 'Update_Form_Controls' routine (see code snippet) in the 'Load' event of all pertinent forms.  The loop I have works pefectly for contols that are in the detail of the form but does not change the captions of any controls in the form header.

What is needed to have the same logic work on the labels in the header of the form?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Public Sub Update_Form_Controls(ByRef frm As Form)

Dim controlType As String
Dim controlName As String
'
Dim c As Control
For Each c In frm.Controls
    '
    controlType = Trim(UCase(TypeName(c)))
    controlName = Trim(UCase(c.Name))
    '
    ' Populate variable label names
    '
    If controlType = "LABEL" Then
        If Mid(controlName, 1, 4) = "Line" Then
            c.Caption = Trim(gStructClient.ReferToLineNumber)
        End If
        If Mid(controlName, 1, 3) = "LotBlock_Label" Then
            c.Caption = Trim(gStructClient.ReferToLotBlock)
        End If
    End If
'
Next
End Sub

Answer : Loop thru controls in from header

I believe your code should work if the labels in the header section are really labels, and not textboxes that are being used as lables.  If your so called header labels are really textboxes used as labels, then your code will have to address that.
Random Solutions  
 
programming4us programming4us