• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 605
  • Last Modified:

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
0
Algorithmix
Asked:
Algorithmix
  • 3
  • 2
  • 2
  • +1
1 Solution
 
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now