VB6, How do I suspend the execution of code in one form until another form is closed?

After opening from2 from code in form1 I'd like to hold the execution of code in form1 until form2 is closed.
How do I do this?

At the moment in one form I have the following code:

If condition is met then:
Me.MousePointer = vbHourglass
mintWindowState = Me.WindowState
If mfrmNewOrder Is Nothing Then Set mfrmNewOrder = New frmOrder
mfrmNewOrder.SetLoadMode LoadModeChild, cboOrderName.Text, cboOrderNumber.Text, "True"
mdiCDB.LoadChild mfrmNewOrder
mbooChildFormOpen = True
Cancel = True

'WOULD LIKE CODE TO HOLD HERE UNTIL frmLineOrder is closed
End if condition is True
AlgorithmixAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you have to main possibilites:

method 1:
 display the form2 as modal form:
 form2.Show vbModal, me

 that way, implicitely, the code in form1 will continue only once the form2 get's closed/hidden

method 2:
 in case you don't want to show form 2 as modal form, you need to use a different method.
 add an event to form2, which you raise on the the Form2's QueryUnload event.
 form 1 must have that event handler defined also, and on that even, call the continuation code part of the above.
 
 this will require much more code, and actually best way might be to put it into a class, but finally might help to organize the code

 





0
 
AlgorithmixAuthor Commented:
Angellll,
I'd like to use method 1. However I'm getting an unhandled error 371 - "The specified object can't be used as an owner form for Show()" ?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I don't see how that could be...
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
peetmCommented:
This isn't an MDI app is it?
0
 
Arthur_WoodCommented:
Is this in a VB6 program, or VBA (such as in Access)?

AW
0
 
AlgorithmixAuthor Commented:
This is a VB6 app.
0
 
peetmCommented:
SYMPTOMS
========

When the MDI child form uses the Show method to open a form, you may
receive the following error:

   Run-time Error '371':
   The specified object can't be used as an owner form for Show().

CAUSE
=====

These errors occur if an MDI child form uses the Show method and specifies
that it owns the form to display. An MDI child form cannot own another
form.
0
 
AlgorithmixAuthor Commented:
OK, I got it. There was other code that was based on form2 being a MDIchild that needed to change also. Thanks for your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.