Why doesn't the label stay on your Form (1 Viewer)

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 09:23
Joined
Jul 9, 2003
Messages
16,243
Finding the Caption of a Label

By way of an example, I utilize the Controls Collection to find a Control's caption in my CallCalled Class Module:-

https://www.niftyaccess.com/callcalled-class-module/

There are two functions in the Class module at the bottom of the page:-

fHasLabel which checks to see if the control actually has a label. It does this by looking at all the labels on the form, finds the labels "parent name", (always a control) then checks to see if it matches the control name passed in. This is an excellent method you can use to check the existence of something, looking for its "text" name because this does not cause a crash, if you try and actually look for a control directly, if it does not exist then you get an error. So doing it this way avoids generating Errors.

And then the function fGetLabel utilizes the function fHasLabel to make sure that control actually has a label. If you try and access the label caption of a label that does not exist, then the code will fail. fGetLabel returns the caption by accessing the controls personal? local? Collection, always Control (0) Zero.....

Sent from my Pixel 3a using Tapatalk
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 09:23
Joined
Sep 21, 2011
Messages
14,037
Tony.
The link for the class module does not work.?
Also says Product Not found
 

Micron

AWF VIP
Local time
Today, 05:23
Joined
Oct 20, 2018
Messages
3,476
Nice explanation. Has anyone ever complained that it didn't work, only to discover that theirs wasn't attached? You do mention attached more than once but don't say that it has to be. It would not surprise me.
 

Users who are viewing this thread

Top Bottom