How to set a form in dialog mode??

P

phpons

Hi all,

I have a form that shows a combo box.
This form is launched by a piece of code from another form.
The VBA code needs to wait that the form has closed befor continuing,
having catch the user selection.

I know how to open the form in dialog mode, using docmd.OpenForm,
formname,,,,,acDialog.

However I start the form by instanciating a form object, like:

Dim frm As Form_myForm
Set frm As new Form_myForm

How can I set the form in dialog mode, so that the code waits until
the form closes?

TIA,

Philippe
 
G

Guest

can't you put the part of the code that needs to wait in the on close event
of the second form?
 
A

Arvin Meyer [MVP]

Try this:

Static colForms As New Collection

colForms.Add New Form_Form1
colForms.Item(colForms.Count).Visible = True
colForms.Item(colForms.Count).Modal = True
 
A

Albert D. Kallal

Unfortatnly, you can't accomplish what you want.

You can set hte form as model, but not as acDialog.

however, note that dialog forms do freeze up everhting..includeing menus
etc.

What I would suggest you do is code as follows:

Dim frm As Form_myForm
Set frm As new Form_myForm

frm.visiable = True
set frm.frmPrevious = me

end sub


Public function Myreturn

..... code here is run after return...


then, in the forms clsoe event, you simply call the sub returing code, or
run the code

frmPrevious.MyReturn

And, you can set/pass vales back to the "my return". If you use a consistent
naming pattern, then the form can be re-used many times for any routines....

The above example assumes that form_myform has a public variable named

dim frmPrevious as form


So, don't code and use acDialog forms anymore..simply make a reference to
the previous form, and then you can run code, set values, set fields etc....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top