Hiding Multiple Forms

tcarriero
NewLounger
Posts: 15
Joined: 10 Feb 2010, 20:13

Hiding Multiple Forms

Post by tcarriero »

I have a form with three command buttons. Each will make a hidden form visible for data correction. Once the correction is made, they will need to remember to close the hidden form before moving on to the next record. I've been instructed to make this as easy as possible so could you please tell me how to write something so they all close with the click of a "Reset" button.

Main Form: frmMaster_Dealers
Three Subforms: sfrmAddress1, sfrmContact, sfrmEmail.
Button: cmdReset

This is what is currently used to make one of the hidden forms visible. All others formated the same with name changes of course.

OnClick: Event Procedure

Private Sub cmdContact_Click()
Me![sfrmContact].Visible = Not Me![sfrmContact].Visible
If Me![sfrmContact].Visible Then
Me![cmdContact].Caption = "-"
Else
Me![cmdContact].Caption = "+"
End If
End Sub

User avatar
StuartR
Administrator
Posts: 12628
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Hiding Multiple Forms

Post by StuartR »

I am not an access expert, but I suspect you want something as simple as...

Code: Select all

Private Sub cmdReset_Click()
    Me![sfrmContact].Visible = False
    Me![cmdContact].Caption = "+"
    Me![sfrmAddress1].Visible = False
    Me![cmdAddress1].Caption = "+"
    Me![sfrmEmail].Visible = False
    Me![cmdEmail].Caption = "+"
End Sub
StuartR


tcarriero
NewLounger
Posts: 15
Joined: 10 Feb 2010, 20:13

Re: Hiding Multiple Forms

Post by tcarriero »

Thank you for trying but it's lit up in red. I'm afraid I don't know what the numbers are so I just pasted as is. Please let me know if I was to make adjustments.

Thanks again.

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Hiding Multiple Forms

Post by Wendell »

It appears to me that code that Stuart suggested should work. It should be pasted into an Event procedure you create by using the builder for the button called "cmdReset" - but the builder will create the first and last lines, and you only should need to paste in the six lines that start with Me! - also what numbers are you referring to? You may need to adjust the button control names if the one for addresses and for email are different than what Stuart used.
Wendell
You can't see the view if you don't climb the mountain!

tcarriero
NewLounger
Posts: 15
Joined: 10 Feb 2010, 20:13

Re: Hiding Multiple Forms

Post by tcarriero »

My mistake! I copied it from the email that I receive in Lotus Notes. That must be where all of the wacky numbers came from! All is well, thank you for the support.

Thank you BOTH!!!