Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511

    Unanswered: Open a Form with a Function and Wait

    I am attempting to open a form with a function in a module, use the form to get a starting and ending date which are both global variables, from the user and then continue in the function to load a table based on the two dates.

    My problem is that the function does not wait after I open the form, which is modal. How do I get the function to wait? To open the form, I use the code: DoCmd.OpenForm "Form1"

    Jerry

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Look in Help at OpenForm and you'll find an argument called acDialog, which will make the code wait.
    Paul

  3. #3
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    Thanks for your reply Paul. The solution to opening a form and having the VBA code wait until the form is closed is:
    DoCmd.OpenForm "Form1", , , , , acDialog

    Jerry

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    One tip that might save you some time. When you use acDialog to open a form, execution of the code after the call will begin when you close or HIDE the form. Whenever I use a form to get user input, I will hide the form, then add some code after the OpenForm to get the data on the form (by referencing the Forms collection) and then have the calling code close the form when it is done.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Example here:
    http://www.dbforums.com/showpost.php...79&postcount=2

    though to be honest you know it all by now anyway.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •