Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing form - vbModal

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
0
0
GB
I do not have an MDI form as a mainform. I am calling up forms with the code Form2.Show vbModal,Form1. The problem is trying to hide the form. I am using Form1.Hide and it gives an error "Must close or hide topmost modal form first - runtime error 402. I do not have any other forms showing other than the main form - any ideas how to solve the problem? Thanks
 
I tried this in a number of ways and was always able to hide Form1 regardless of it being modal or not...anyway try this.

'in the event that opens form2 eg. command1_click on form1

Private Sub Command1_Click()

Form1.Hide ' hide form1 first
Form2.Show vbModal ' then open the modal form

End Sub

Good Luck!!!
 
Thanks MakeShift, I am an idiot. I just came online to avoid looking daft but was too late. I found I was trying to close a form that wasn't open, I had used the wrong form name on the hide statement, having now corrected that it works. Thanks again for comming back, regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top