Suspend code when form opens

  • Thread starter Thread starter Ian
  • Start date Start date
I

Ian

My code is processing and when it needs a user decision it
opens a form but the code carries on processing. I need
it to stop until the user has made the decision, then
carry once the decision is made (the user clicks one of
three command buttons). I've tried
DoCmd.Openform "strFrmName",,,,,acDialog and all varieties
of setting the form's modal and pop-up properties, to no
avail, the code just carries on.
Thanks
 
Opening the form in dialog mode should work, unless the form is already
opened, is opened hidden, or you are already doing something modal.
 
Hmm,
DoCmd.OpenForm "frmName", acNormal, , , , acDialog

I just tried this & it stopped execution on my parent form until I closed
the child form...

Using this in conjunction with setting the form as a modal form should mean
that nothing happens until the user dismisses the child form...
 
Allen
I tried again - same result. The form is not loaded or
visible prior to this code. In fact nothing else in open
or running in Access except the code. Here is my code
that is in a sub in a module:
Dim strFormName As String
strFormName = "frmPreferencesOtherSF"
DoCmd.OpenForm "strFormName", , , , , acDialog
MsgBox "I've now reached here!"
Normally I would test for the user action by examining a
global variable.
The form loads but so does the messagebox.
I have just tried DoEvents with disastrous results, as I
did not know what to do to stop DoEvents and the Access
Help file don't really explain how long DoEvents lasts or
what stops it. I could not get control of Access again
not save any changes. Had a backup and replaced the
entire db to get back to normal.
Any more ideas?
Ian
 
James
Thanks. The code is in a sub in a module.
The code is:
Dim strFormName As String
strFormName = "frmPreferencesOtherSF"
DoCmd.OpenForm "strFormName", , , , , acDialog
MsgBox "I've now reached here!"

Normally, I would test for which command button the user
clicked. The form loads but so does the Messagebox!

The form is not visible or loaded before this code. The
only thing running in Access is the code. Nothing else is
open or visible.

The form is Dialog, Modal and PopUp.
Any ideas?
Ian
 
James
It now works. I was being fooled by making a change to
the form's code and it then placing the form into design
view which apparently stops its dialog properties. Also,
the snippet of code I show below had an error in it as
there should not have been quotes around the form name as
it is a variable but this code was just for this query.
Ian
 
Allen
It now works. I was being fooled by making a change to
the form's code and it then placing the form into design
view which apparently stops its dialog properties when
opened by the code.
Also, the snippet of code I show below had an error in it
as there should not have been quotes around the form name
as it is a variable; but this code was just for this query.
Not sure how to reply to two folk who give answers. Do I
do it individually as I've doen here or at the top level
of my original posting?
Ian
 
Good. Glad you got it solved.

Yes, if the form is already open (in design view), that does make a
difference.

Answers to each thread is fine.
 
Back
Top