By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,284 Members | 1,697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,284 IT Pros & Developers. It's quick & easy.

Wait for user to close form

P: 2
I have a module I'm building that kicks off with a button click. I need the module to do the following...
* some various housekeeping stuff and data collection (done)
* open a form (done)
* fill in fields of the form (done)
* excute a private function stored with the form (???)
(performs updates to other fields in the form)
* have the module WAIT until the form is closed by the user (???)
* resume the module (???)

Here's a code snippet of what I have so far...

Expand|Select|Wrap|Line Numbers
  1.     Do While Not rsCustNum.EOF
  2.         DoCmd.OpenForm "frmInvoicesLookup"
  3.         With [Forms]![frmInvoicesLookup]
  4.             ![filterToEmail].Value = "True"
  5.             ![DateFrom].Value = Date - 8
  6.             ![DateTo].Value = Date
  7.             ![CustomerNumber].Value = rsCustNum!CustomerNumber
  8.         End With
  9. CustomerNumber
  10. ' ---
  11. '      need to set focus to the form in question,
  12. '      execute the private function,
  13. '      and wait for the form to close
  14. ' ---
  15.         rsCustNum.MoveNext
  16.  
How do I do what is marked as the comment in the above code?

For the 'execute private function' part I could setup code for the form's On Open event that checks for "True" in the filterToEmail field and then calls the private function in question... although I'd rather try to call it from the Module if at all possible.

It's the setting focus to the form and waiting for it to be closed parts that have me stopped.

Thanks!
Oct 12 '06 #1
Share this Question
Share on Google+
2 Replies


100+
P: 143
A form won't close on it's own. It takes user intervention on their part, unless you have programmed it to do so after an event has finished.
Oct 13 '06 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
Is this what you're looking for?

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Do While Not rsCustNum.EOF
  3.         DoCmd.OpenForm "frmInvoicesLookup"
  4.         With [Forms]![frmInvoicesLookup]
  5.             ![filterToEmail].Value = "True"
  6.             ![DateFrom].Value = Date - 8
  7.             ![DateTo].Value = Date
  8.             ![CustomerNumber].Value = rsCustNum!CustomerNumber
  9.         End With
  10.         DoCmd.Close acForm, "frmInvoicesLookup"
  11.  
  12.         rsCustNum.MoveNext
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
Oct 14 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.