The problem here is popup and modal forms don’t’ halt calling code.
But worse is your need to halt calling code. That requires a dialog form.
And more worse is a dialog form does NOT allow re-sizing.
You don’t want to confuse the 3 types of forms here.
Modal forms – they are different then popup forms, and very different from dialog forms.
And same goes for Popup forms. They are not dialog forms, and in fact they are also not model.
You also have to take into consideration if you Access application is set to use tabbed documents, or overlapping windows. (this will limit your choices again).
If you using tabbed interface, then you have to use a popup form if you want re-sizable ability – but this type of form will not halt calling code.
If you using overlapping windows, then I recommend a modal form. (But again it will not halt calling code, but will allow re-size).
While you “could” adopt some looping code in the calling form that “waits” for the second form to be dismissed, such loops are processor hogs and often cause a “poor” response in terms of mouse and typing.
So I would suggest that change your code approach. Have the calling form launch the form as popup (or modal if you not using the tabbed interface).
Then when you close the form, it calls some more code that you want to run in the calling form. This does mean you have to split out the code that you want to run after closing that 2nd form – and have the closing form call + run that code.
A “general” approach should avoid hard coding the forms names since then “many” routines and forms can call your second forms and that facilities re-use of such forms.
So try this:
In the second form, create a module level form variable like this:
Option Compare Database
Option Explicit
Dim frmPrevious As Form
In the forms on-open event of this form, GRAB the calling forms refeance like this:
Set frmPrevious = screen.ActiveForm
Now in the forms close event , do this:
frmPrevious.AfterClose
And in the calling form, create a public function called
AfterClose
So in the public function in the first form, you place the code that you want to run when you close the 2nd form. This is "less" ideal then nice procedural code that calls the 2nd form, waits and continues - but I think it still about the best choice.
And before you close, you can pass or “set” values to return to the calling form like:
frmPreviuos.SomePubicVar = me!LastNameSelected
frmPrevious!Company = me!CompanySelected
frmPrevious.AfterClose
In the above the first line sets a public variable in the calling form (if you want to do that and pass values back to module level vars in the first form). And the next line sets the value of a control in the calling form (if you want to pass values back to some controls on the calling form).
And the 3rd line executes the MyClose code in the calling form. And if you have some kind of “ok” or select button in that second form, then move the above code to behind that button – since you may not want such code running if the form has a cancel button (so the cancel button would simply close the form – but not call + run the above code in the first form). And hitting the X would also be assumed to be a cancel or exit. So your "save" or "ok" or "select" button would have the above code.