Text Box Events Problem (1 Viewer)

AOSB

Registered User.
Local time
Yesterday, 23:11
Joined
Sep 12, 2011
Messages
18
Hello, I have a form bound (data entry) to a table; there is a text box on the form which is NOT bound to that table. It is bound to a Dlookup on another table. It all works fine. Here is the BUT.
I would like the textbox.visible property to be True ONLY if there is any text in it.
I cannot find which event to put the VBA code in to achieve this.
I could do it easily if I was typing into the box but none of the Events seem to fire when the Dlookup populates it.
Any ideas please?
 

RuralGuy

AWF VIP
Local time
Today, 00:11
Joined
Jul 2, 2005
Messages
13,826
How about populating the TextBox in the Current Event of the Form and check the contents there and set the Visibility as well?
 

vbaInet

AWF VIP
Local time
Today, 07:11
Joined
Jan 22, 2010
Messages
26,374
Or if the textbox is transparent and is borderless, just populate the textbox (like RuralGuy said). If there's no data returned it will inadvertently make the textbox "invisible".
 

AOSB

Registered User.
Local time
Yesterday, 23:11
Joined
Sep 12, 2011
Messages
18
Thanks for the quick replies. RuralGuy had the exact answer I was looking for. I thought, wrongly, that the On Current event occurs only when a form is opened. I now know that it also fires whenever the focus leaves one record and moves to another. The clue was in the name of course - On Current refers to the current record changing not the form becoming the current one. Thanks RuralGuy for putting me on the right track.
VbaInet also has made me think that his method might come in very handy one day.
 

PNGBill

Win10 Office Pro 2016
Local time
Today, 18:11
Joined
Jul 15, 2008
Messages
2,271
Conditional Formating is another option.
 

Users who are viewing this thread

Top Bottom