Display Name
Display Name

Reputation: 1

Hide/Unhide Userforms in VBA Excel

I'm creating a system that allows an individual to select module choices for their degree.

The users have to navigate between multiple forms (e.g. semester 1 & 2, user info, confirmation pages etc.). I want the users to be able to return to a previous form to make changes after progressing (i.e. return to semester 1 choices after moving onto semester 2 choices) and be able to still edit all the data they inputted into the first form.

I have tried using the hide and show methods but I keep getting an error (Run Time error '400' - Form already displayed, cannot show modally)

'on the AM1 form

AM2.Show

AM1.Hide
   '(first form I want to close)

'on the AM2 form

Unload me

AM1.Show
     '(I want to return to the first form and close the second)

I want to be hide the first form (AM1) and keep all the info available to be re-edited when successfully returning to it.

Upvotes: 0

Views: 5930

Answers (1)

RCL
RCL

Reputation: 276

Try hiding AM1 first before showing AM2 and that should fix your issue.

Private Sub CommandButton1_Click()
 UserForm1.Hide
 UserForm2.Show
End Sub

Also I think using the multipage control is probably better than using multiple userforms.

Upvotes: 1

Related Questions