silentwolf
Active member
- Local time
- Today, 14:39
- Joined
- Jun 12, 2009
- Messages
- 575
Hi,
I like to update label Captions within a form.
However I am only able to get the control Name and not the caption of that control.
The reason I like to update all Labels in a Form as I have always something like Cont_FirstName and so on..
I like to get rid of the "Cont_" so the caption is "Firstname"
Once I am able to receiving the Caption I am able to update that Label so I was hoping someone could help please.
Would be just nice as there are many Forms and Controls so it would be a nice thing to have.
Many thanks
I like to update label Captions within a form.
However I am only able to get the control Name and not the caption of that control.
The reason I like to update all Labels in a Form as I have always something like Cont_FirstName and so on..
I like to get rid of the "Cont_" so the caption is "Firstname"
Code:
Sub Test()
Dim ctl As Access.Control
Dim strOld As String
strOld = "Cont_"
Dim strNew As String
strNew = ""
For Each ctl In Forms!frm_Contacts ' must be open in design view
If ctl.ControlType = acLabel Then
Debug.Print ctl.Name
Dim strLabel As String
strLabel = ctl.Name
Debug.Print me.(ctl.Name).Caption) 'How To get this Property when not knowing the Control Name
End If
Next ctl
End Sub
Once I am able to receiving the Caption I am able to update that Label so I was hoping someone could help please.
Would be just nice as there are many Forms and Controls so it would be a nice thing to have.
Many thanks