set to invisible

  • Thread starter Thread starter Miranda
  • Start date Start date
M

Miranda

hi,

i have a form that has a couple of text boxes, list box and combo box that
shows some records from one of my tables. I'm using a macro, to judge if the
combo box is empty (FORMS!MyForm!listBox!listcount) this works fine. But if
the combo box is empty i want to set all of the text boxes, combo boxes etc
on this form to invisible....so people should only be able to view the
things on the form if there are values in the combo box. How do i go about
setting everything to invisible in a macro??

thanks in advance,

miranda
 
Miranda,

I'm not sure if this can be done through a macro (I've given up on them for
quite some time), but it can definitely be done with a few lines of code,
something like:

Sub hide_controls()
lcount = False
If Forms!MyForm!listBox!listcount > 0 then Lcount = True
Forms!MyForm!Control1.Visisble = lcount
Forms!MyForm!Control2.Visisble = lcount
....
End Sub

Substitute Control1, Control2 etc. with your actual control names, paste the
code in a module and use whatever event you use to run the macro, to run
this code instead (or, if you are doing other things as well in the macro
and want to keep it, just change chnage the word Sub to Function in the
first and last line, and run it from the macro with a Runcode action).

Note: this code works both ways, i.e. it sets the controls back to visible
if the listbox has entries.

HTH,
Nikos
 
Back
Top