Hide empty text boxes

G

Guest

I select records using a combo box on the form header. I have text boxes on a
subform that display the fields of the selected record.

I want to hide all text boxes on the subform that don't contain data.

Thank you
 
G

Graham Mandeno

Hi Peter

You can set each control's Visible property in the Form_Current event
procedure.

SomeControl.Visible = Not IsNull(SomeControl)

If you have a number of these, you could use the control's Tag property to
identify it as a candidate for checking. For example:

Dim ctl as Control
For Each ctl in Me.Controls
If ctl.Tag = "X" then ctl.Visible = Not IsNull(ctl)
Next ctl

Note that you can't make a control invisible if it currently has the focus,
so first SetFocus to one that is not a candidate.

Also, if your subform is continuous then this will affect the controls in
all records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top