Form Labels Question

G

Guest

Hello all,

Is it possible to toggle the visibility of labels on a form? I have two
labels stacked on top of each other, one is visible and the other has
visibility turned off. What I would like to do is have a user click a button
to toggle the visibility of both labels, but only have one or the other be
visible.

Button and Label names follow:

Button Name = lblToggle
Label 1 Name = lblAgent
Label 2 Name = lblCorporate

Thanks in advance...

-Sky
 
D

Dirk Goldgar

Sky Warren said:
Hello all,

Is it possible to toggle the visibility of labels on a form? I have
two labels stacked on top of each other, one is visible and the other
has visibility turned off. What I would like to do is have a user
click a button to toggle the visibility of both labels, but only have
one or the other be visible.

Button and Label names follow:

Button Name = lblToggle
Label 1 Name = lblAgent
Label 2 Name = lblCorporate

Your button is named "lblToggle"? That's confusing, since the "lbl"
prefix is usually used for labels. Anyway, the code for the button's
Click event could look like this:

'----- start of code -----
Private Sub lblToggle_Click()

Me!lblCorporate.Visible = Me!lblAgent.Visible
Me!lblAgent.Visible = Not Me!lblAgent.Visible

End Sub
'----- end of code -----
 
G

Guest

Dirk,

Good catch. That button name was a typo on my part. Should have read as
"btnToggle".

Anyway, your code worked smoothly without flaw. Labels toggle really well
and now I can add some color and detail to make them stand out.

Thanks a million Dirk for your help with this one. My database looks great
thanks to all the help from everyone reading my posts. This site rocks!!!

-Sky
 

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