Visible Only When Needed

Randomblink

The Irreverent Reverend
Local time
Today, 04:34
Joined
Jul 23, 2001
Messages
279
Ok...
I have a LONG drawn out process for this and I am sure that there is an easier way to take care of this without writing thousands of lines of code...

I currently have about 10 fields and their labels that need to disappear and reappear...

5 of them are Alternate Mailing Fields and their labels...
The other 5 are Main Mailing Fields and their labels...

What I want to do is write a procedure/sub/function that will pop them in and out as called...

What I have now is a line of code that looks like this...

Private Sub Alternate_Hide()

Field1.Visible = True
lbl_Field1.Visible = True
Field2.Visible = True
lbl_Field2.Visible = True
Field3.Visible = True
lbl_Field3.Visible = True

Field09.Visible = False
lbl_Field09.Vixible = False
Field08.Visible = False
lbl_Field08.Vixible = False
Field07.Visible = False
lbl_Field07.Vixible = False

End Sub

Then I reverse the procedure and call it:

Private Sub Main_Mailing()

and I reverse the false and true statements...

Is there anyway that I could set it so that...

If X.visible = True
X.Visible = False

???

I get lost in coding like that...
If someone could help me out it would be greatly appreciated....

The thing is, this is only for looks right now...and to shorten the code would be nice, besides I see future uses for such a code...
Thanks ahead of time...
 
Unless the number of fields involved gets much larger, a simple way to do it would be to replace your two procedures with one, something like this:

Sub SetIt(Setting as Boolean)
Dim Opposite as Boolean
Opposite = Not Setting
'make these fields visible if Setting = True,
'or invisible otherwise
Field1.Visible = Setting
lblField1.Visible = Setting
...
'set the visibility of these fields to the
'opposite of the first group
Field9.Visible = Opposite
lblField9.Visible = Opposite
...
End Sub
 
How would I call these...?
I do not understand in the least HOW the code you recommend would work...
But if I were to put the code in there, how would I call it from two different buttons?
I have one button for Alternate and one for Main...
When I press Alternate...the Main Address disappears...and vice versa...
 

Users who are viewing this thread

Back
Top Bottom