Make visible on click, part 2

O

Opal

Doug Steele helped me with this last
week:

Private Sub MyCommandButton_Click()

Me.Parent!Subform2Control.Visible = Not Me.Parent!
Subform2Control.Visible

End Sub


I need to through another wrench into this
after this subform is visible, I need another
label and button visible too.....

Would I do something similar with the On current
of the now visible subform?
 
D

Dirk Goldgar

Opal said:
Doug Steele helped me with this last
week:

Private Sub MyCommandButton_Click()

Me.Parent!Subform2Control.Visible = Not Me.Parent!
Subform2Control.Visible

End Sub


I need to through another wrench into this
after this subform is visible, I need another
label and button visible too.....

Would I do something similar with the On current
of the now visible subform?


I don't see that the Current event of the subform would be useful, as that
will fire regardless of whether the subform is visible or not. Why not use
the same code that shows or hides the subform to show or hide the label and
button as well? Something like:

Private Sub MyCommandButton_Click()

Dim blnVisible As Boolean

blnVisible = Not Me.Parent!Subform2Control.Visible

Me.Parent!Subform2Control.Visible = blnVisible
Me.Parent!SomeLabel.Visible = blnVisible
Me.Parent!SomeButton.Visible = blnVisible

End Sub

The above assumes that all the controls you want to hide are on the parent
form, but you could easily modify it to refer to controls on the current
form or elsewhere.
 
O

Opal

Hi Dirk,

Just to clarify, both subforms are bound and on an unbound
main form. The additional label and command button are
also on the the main form.

Subform 1 is always visible, on a button click in subform
1, subform 2 is made visible and I want the label and
command buttom made visible at the same time.

I tried what you suggested..... and, its really strange,
but I am being told that subform 1 is in design view
and cannot be opened???
 
D

Dirk Goldgar

Opal said:
Hi Dirk,

Just to clarify, both subforms are bound and on an unbound
main form. The additional label and command button are
also on the the main form.

Subform 1 is always visible, on a button click in subform
1, subform 2 is made visible and I want the label and
command buttom made visible at the same time.

Then in principle, the code I suggested should work -- after you've adjusted
the names, of course.
I tried what you suggested..... and, its really strange,
but I am being told that subform 1 is in design view
and cannot be opened??? [from followup message]
Sorry, error is for subform 2, not subform 1

I don't see how that could be related to the code I posted. When do you get
this message? When you open the main form, or when you click the button?

*Was* the second subform open in design view when you ran the code? Did you
save your code changes and close all objects that were open in design view,
and then reopen the main form?

If it's still misbehaving, please post the exact code you're using.
 

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