What I’d like to do is display the description from the currently selected field in a label on my form. I feel that where it is currently being displayed (the bottom left status bar) is barely noticeable.
How do I access that value in the status bar? For example, on my form, when I have a say, employee name field selected, in the bottom left in small print, it displays “The name of the employee you are registering.”
I know in some event on my form, I need code that does
me.lblControlDescription.Caption = me.statusbar.caption
How do I access the text in the status bar (the field description) in VBA?
The text in the status bar is the current field’s
Descriptionproperty.From VBA, you can access the
Descriptionof a field in the form’s recordset.So, if you have a label control named
lblDescription, you can set its.Captionvalue to the field’sDescription.However, this could be more complicated.
Descriptionis a user-created property, which means that it doesn’t exist until you give it a value. And, if you have one set, but delete its value later, the property itself no longer exists.If you attempt to retrieve the
Descriptionwhen one doesn’t exist, VBA will throw error #3270, “Property not found.” You could trap that error, and setMe.lblDescription.CaptiontovbNullStringwhen it happens.You also need a strategy for when to change
Me.lblDescription.Caption. You could create a procedure to set it based on the current active control. Then call that procedure from the on focus event of each of your form’s controls. There may be a better approach for this, but I’m not seeing one just now.