Hi Mark,
Thanks for the quick reply. I have been working today on modifying code to change labels on a new form. I am not a masterful programmer, but I am enclosing what I have done for your review. It may be crude, but now does what I am looking to do. I am sure it can be more elegant, but that may come.
Function CheckFormControls()
Dim f As AccessObject
Dim frm As Form
Dim ctl As Control
Dim captionstr As String
Dim spacepos As Integer 'position of space
Dim l As String ' left
Dim r As String ' right
Dim NewLabel As String
Dim namestr As String
For Each f In CurrentProject.AllForms
DoCmd.OpenForm f.Name, acDesign, , , , acHidden
Set frm = Application.Forms(f.Name)
For Each ctl In frm.Controls
If TypeOf ctl Is Label Then
If ctl.Name = "theNameOfLabel" Then
frm("theNameOfLabelHere").Caption = "xxxx"
End If
'---------------------------
Debug.Print "Form:" & " " & f.Name
captionstr = ctl.Caption
namestr = ctl.Name
Debug.Print ctl.Caption
'Debug.Print ctl.Name
'Debug.Print Len(Trim(ctl.Caption))
spacepos = (InStr([captionstr], " "))
'Debug.Print spacepos
If spacepos > 0 Then
l = Left([captionstr], spacepos - 1)
r = Right([captionstr], Len(ctl.Caption) - spacepos)
NewLabel = "lbl" & Trim(l) & Trim(r)
Debug.Print NewLabel
ctl.Name = NewLabel
Debug.Print "-------------" 'this line is between labels
End If ' if spacepos > 0
If spacepos = 0 Then 'we know it is single word
l = Trim([captionstr])
NewLabel = "lbl" & Trim(l)
Debug.Print NewLabel
ctl.Name = NewLabel
End If
End If ' if TypeOf ctl is Label
' write it here
Next 'next ctl
Set frm = Nothing
DoCmd.Close acForm, f.Name, acSaveYes
Debug.Print "________________________" ' This line is Between Forms
Debug.Print "------------------------"
Next
'Next f
End Function
Thanks, please feel free to make it better. Thanks John