John W. Colby
jwcolby at colbyconsulting.com
Tue Jan 18 20:43:49 CST 2005
Here ya go, working code from my framework that finds the label if it
exists.
'.Comments :
'.Parameters:
'.Sets :
'.Returns :
'.Created by: John W. Colby
'.Created : 6/17/02 11:22:19 AM
'
'Finds the label that "belongs to" any given control.
'
Function CtlLbl(ctlFindLbl As Control) As Label
On Error GoTo Err_CtlLbl
Dim ctl As Control
For Each ctl In ctlFindLbl.Controls
If ctl.ControlType = acLabel Then
Set CtlLbl = ctl
End If
Next ctl
Exit_CtlLbl:
Exit Function
Err_CtlLbl:
Select Case err
Case 0 '.insert Errors you wish to ignore here
Resume Next
Case Else '.All other errors will trap
Beep
MsgBox err.Description, , "Error in Function Utils.CtlLbl"
Resume Exit_CtlLbl
End Select
Resume 0 '.FOR TROUBLESHOOTING
End Function
In my framework, every control class has a label variable in the class
header. The init method just calls this function to find the label and set
the label variable so that if the control class ever needs to use the label
(change the back color, font etc it can just do so.
Private WithEvents mcbo As Access.ComboBox
Private mlbl As Label
Function Init(lcbo as combobox)
set mcbo = lcbo
Set mlbl = CtlLbl(mcbo)
End function
etc
John W. Colby
www.ColbyConsulting.com
Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Lonnie Johnson
Sent: Tuesday, January 18, 2005 4:08 PM
To: AccessD solving'
Subject: [AccessD] Grab a text box's label's caption in code.
Can I somehow call the name of a textbox and get the caption of it's label?
I don't see a label property for a textbox.
Just curious.
May God bless you beyond your imagination!
Lonnie Johnson
ProDev, Professional Development of MS Access Databases
Visit me at ==> http://www.prodev.us
---------------------------------
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com