Results 1 to 4 of 4
  1. #1
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67

    Want calling program not to continue until called form has been closed

    I have a form F_SelectDeck whose function is to allow the user, by interacting with the form, to set the value of a global integer DeckSelected. By itself the form works properly. I was under the impression that if the form's modal property were set to yes, then after calling the form the code after the code which called the form would not execute until the form was closed. Evidently this is not the case.




    I have the following code.
    Sub SelectDeck()
    DoCmd.OpenForm "F_SelectDeck"
    End Sub

    Sub Test09()
    SelectDeck
    MsgBox "The Deck selected was " & SelectedDeck
    End Sub

    When I run Test09 I immediately get the message "The Deck selected was " followed by the original value of SelectedDeck, which is not what I want. What I want is for program execution to not continue until F_SelectDeck has been exited. The modal property of F_SelectDeck is set to yes.

    How might I get the program to operate as I want it to?

    Thanks in advance.

  2. #2
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67
    AHAH!!!

    I just found the answer by using the searchbox on this forum and typing in "modal form" and then looking at the various posts until I came to one that showed the same issue as mine.

    Our esteemed "Wino Moderator" answered the same question almost 5 years ago. I'd put the link here but I haven't figured out how to do that yet.


    Paul suggested setting acDialog as the acWindowMode parameter in the Docmd.openform command. I wasn't sure what that meant, but I used the help file in Access VB and searched "Openform" and clicked on a promising reference and found that acWindowMode is the sixth parameter in the openform command. I then clicked on the acWindowMode and found several options, on of which was acDialog, which sets the forms modal and popup properties to yes. So my code works perfectly if I replace

    DoCmd.OpenForm "F_SelectDeck"

    with

    DoCmd.OpenForm "F_SelectDeck", , , , , acDialog


    Thanks Paul

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    You could do
    DoCmd.OpenForm "f_SelectDeck", acNormal, , , , acDialog

    your global assignment must be done in a PUBLIC module and assigned before form exit

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Great job researching..

    And thanks for posting your solution... I'm sure it will help someone else.


    Ready to mark this solved?

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

Similar Threads

  1. Replies: 5
    Last Post: 01-24-2014, 09:05 AM
  2. Replies: 2
    Last Post: 11-08-2012, 11:04 AM
  3. Form not getting closed at first time
    By vikasbhandari2 in forum Programming
    Replies: 10
    Last Post: 07-20-2012, 01:25 PM
  4. Replies: 4
    Last Post: 08-17-2011, 05:30 AM
  5. Replies: 4
    Last Post: 08-16-2011, 10:04 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