Control order of events within a procedure

X

XP

For example, consider the following:

DoCmd.OpenForm "frmCalendar"
Forms("frmCheckEntry").Controls(gcsControlRunDate).Caption = gdCalendarDate

The above code is in a Form class module. Both lines of this code run
immediately when called. What I would like to do is have the first line of
code fire, and open the form; but I want the code to pause until the form is
closed, then and only then, run the second line of code. --Because the
variable gdCalendarDate is not populated until the calendar form is clicked
(and closed).

What I am really trying to accomplish is to reuse a generic calendar form
without having to create eight separate calendar forms that are identical
except for the underlying code that does something based upon the calling
routine, if that makes sense.

If you understand this post (or need clarification) and have an idea, please
post a response. Thanks.
 
S

Stefan Hoffmann

hi,
DoCmd.OpenForm "frmCalendar"
Forms("frmCheckEntry").Controls(gcsControlRunDate).Caption = gdCalendarDate

The above code is in a Form class module. Both lines of this code run
immediately when called. What I would like to do is have the first line of
code fire, and open the form; but I want the code to pause until the form is
closed, then and only then, run the second line of code.
Forms with this kind of behavior are called modal forms.

Use

DoCmd.OpenForm "frmCalendar", , , , , acDialog


mfG
--> stefan <--
 
D

Douglas J. Steele

I'm assuming that gdCalendarDate is a global variable that's populated by
frmCalendar. If so, open frmCalendar as a modal form, so that all processing
stops until it's closed:

DoCmd.OpenForm "frmCalendar", WindowMode:=acDialog

note that's :=, not = with the named parameter.
 

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