Results 1 to 4 of 4
  1. #1
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79

    Stop executing code when Form opens

    Hi,



    I have a form named 'FJobOverview_QueryView' opens by VBA code. See beneath. However, the code opens the form and the code continues executing directly after DoCmd.OpenForm"FJobOverview_QueryView" without the from is closed. I want the code to stop so long the form is opened and then continue when the form is closed by the user manually clicks 'Close' in form. Is that possible?

    (In Excel it's possible to use vbModeLess to not stop the code. I don't know how it works in Access. It's diiferent I can see)

    Code:
    Sub Test()
        '...
        DoCmd.OpenForm "FJobOverview_QueryView"
        'Code contiunes here without I have closed the form above. Can I prevent that codes continues until form above is closed?
        '...
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    yes , make the form MODAL, and it will wait until closed to continue...
    set the form property MODAL = TRUE
    then open the form as dialog:
    DoCmd.OpenForm "FJobOverview_QueryView",,,,,acDialog

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Quote Originally Posted by Joakim N View Post
    Hi,

    I have a form named 'FJobOverview_QueryView' opens by VBA code. See beneath. However, the code opens the form and the code continues executing directly after DoCmd.OpenForm"FJobOverview_QueryView" without the from is closed. I want the code to stop so long the form is opened and then continue when the form is closed by the user manually clicks 'Close' in form. Is that possible?

    (In Excel it's possible to use vbModeLess to not stop the code. I don't know how it works in Access. It's diiferent I can see)

    Code:
    Sub Test()
        '...
        DoCmd.OpenForm "FJobOverview_QueryView"
        'Code contiunes here without I have closed the form above. Can I prevent that codes continues until form above is closed?
        '...
    End Sub

    Any use?

    http://stackoverflow.com/questions/2...-automatically

  4. #4
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Thanks,

    DoCmd.OpenForm "FJobOverview_QueryView",,,,,acDialog

    worked great!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query not properly executing within VBA code
    By kewelch in forum Queries
    Replies: 1
    Last Post: 07-17-2013, 01:12 PM
  2. Code executing without errors, but not working
    By The Professor in forum Programming
    Replies: 13
    Last Post: 02-18-2013, 04:09 PM
  3. Replies: 7
    Last Post: 01-29-2012, 07:44 AM
  4. Problems Executing SavedQuery in Code
    By RMittelman in forum Programming
    Replies: 4
    Last Post: 06-18-2011, 02:49 PM
  5. Replies: 3
    Last Post: 09-16-2010, 09:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums