Modal Form instance

  • Thread starter Thread starter Gary D.
  • Start date Start date
G

Gary D.

In Access97, I want to open a form from within a standard VBA module
and display an alert message giving details of errors or other
notifications.

Presently, I use the following:-
DoCmd.OpenForm "ALERTPANE", acNormal, _
acDialog, , acReadOnly, , varMessage
which opens the form okay.
However, the module that perform this OpenForm continues processing
immediately without waiting for a user response, which is what I want.
I've set the form as modal, pop-up and dialog border, but still get
the same result: execution of the main module continues immediately.

Looking in Help, I have found very brief information about opening
multiple instances of a form, but when trying to compile the suggested
code I receive a compile error.
The code taken from Help is:-
Dim frm As New ALERTPANE
frm.Visible = True
where ALERTPANE is my form. The compile error message says
"User-defined type not defined", yet I've copied this code from Help.
Any clues?

I'm not even sure I can achieve opening a form and waiting for a
response using the above technique anyway. Is there perhaps an
alternative method of doing this?
 
Hi Gary,

Instead of using a form for the alert message, use msgbox. The code
automatically will stop other processing until the message box is closed.

Jim
 
Hi Gary,

Instead of using a form for the alert message, use msgbox. The code
automatically will stop other processing until the message box is closed.

Jim

Thanks Jim

But I wanted to use a form as it offers better formatting than MsgBox,
which is what I use already.

G.
 
Gary,

I have done this very thing before in some of my applications. The way
to handle it is as follows:

1) Create a global variable that can be accessed by both forms. (I called
mine Busy)
2) Right before you open your secondary form, set the variable to a known
value (True)
3) Open the secondary form.
4) Use code similar to the following to check the global variable.
While Busy
DoEvents
Wend
5) In the close event of your secondary form, set busy to a different value
(False) right before it closes.


This will cause the first form to "pause" while the second form does its
processing.

HTH
Keith
 
Presently, I use the following:-
DoCmd.OpenForm "ALERTPANE", acNormal, _
acDialog, , acReadOnly, , varMessage
which opens the form okay.
However, the module that perform this OpenForm continues processing
immediately without waiting for a user response, which is what I want.

Your above code is wrong, you need:

DoCmd.OpenForm "ALERTPANE", acNormal, _
, , acReadOnly, acDialog, varMessage

If you fix the above, then the code will halt. And by the way, model forms
don't wait...acDialog ones do. acDialog forms, and model forms are
COMPLETELY DIFFERENT. You can read about them here:

http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html
 
Your above code is wrong, you need:

DoCmd.OpenForm "ALERTPANE", acNormal, _
, , acReadOnly, acDialog, varMessage

If you fix the above, then the code will halt. And by the way, model forms
don't wait...acDialog ones do. acDialog forms, and model forms are
COMPLETELY DIFFERENT. You can read about them here:

http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html

Thanks Albert

I've changed the code using your version and it works as I intended.
Incidentally, I also previously used
DoCmd.OpenForm "ALERTPANE", , , varMessage
and suffered the same result as my first/earlier version.

But it works now.
Cheers!
 
Back
Top