Pausing Code when a form is called

03-19-2003, 03:29 PM
Here is a problem I've been working on for awhile...

I have some code running, say it is this

Sub main()
Load Form1
Form1.Visible = true

MsgBox "Form 1 has finished processing"
End Sub

Now in Form 1 I have some text fields to enter customer information. But what happens is that the form is showing and then RIGHT after that the msgbox is popping up (out of order)....

this might be a bad example, but basically what i'm asking is: Is there some way to pause the code in Sub Main from running until Form1 has been processed?

ralph m.

03-19-2003, 04:01 PM
You can show Form1 w/an argument of vbModal.

03-19-2003, 04:55 PM
I'll do it with a flag and a while, i know its a cheap way but i dont know other way to do it...

like this...

Public Done as Boolean
Sub main()
Load Form1
Form1.Visible = true

loop Until Done

MsgBox "Form 1 has finished processing"
End Sub

in the form_queryunload you set Done=true and thats it.
but keep searching sure would be a better way.


03-21-2003, 10:23 AM
What jayceepoo ment was that you should write

Sub Main()
Form1.Show vbModal
MsgBox "Form 1 has finished processing"
End Sub

The default argument for the Show method is vbModeless, which has a result that the Show methods returns to its caller and continues executing while the form is visile.

03-21-2003, 10:49 AM
Make sure that you hide the form and not unload it if you want to get the info off the form. You can also store the data on the form in Public variables prior to unloading the form and then retrieve them wherever they are needed. Which way you handle it depends on the need for the data at a particular scope.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum