Reference the the label associated to a Text Box

George Too

Registered User.
Local time
Today, 14:32
Joined
Aug 12, 2002
Messages
198
God I'm such a newbie! :(

Hello guys,

I want to know if it is possible to reference the the label associated to a Text Box.

Here is my code:

For Each control In Me.controls
If control.ControlType = acTextBox Then
If IsNull(control.Value) Then
MsgBox( "" & control.controlname & " is a needed entry")
control.SetFocus
Exit Sub
End If
End If

My question lies in the MsgBox statement. Instead of getting the control name, I want to get the caption displayed in the attached label for that particular control.

Can I?

Thank once again guys,
George
 
You wrote
<<
My question lies in the MsgBox statement. Instead of getting the control name, I want to get the caption displayed in the attached label for that particular control.

Can I?
>>

Not as far as I know. The label is just another control on the form and is not linked to any specific textbox.

Look into the "Tag" property of the text box. You can stick a text value in the Tag property and refer to the property in code.

RichM
 
Got it! :D

Thanks Rich
 

Users who are viewing this thread

Back
Top Bottom