Results 1 to 9 of 9
  1. #1
    mredmond13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    Louisiana, USA
    Posts
    16

    acDialog not pausing code

    I have two problems actually, but I'll address them one at a time:

    I have a form, as shown below:

    Click image for larger version. 

Name:	Main Form.jpg 
Views:	24 
Size:	67.2 KB 
ID:	34662



    When the user selects an item from the menu on the left, the appropriate list is displayed in the area on the right. All working great.

    When the Case List is displayed, I give them the option to select filters. I use a pop-up form. See below.

    Click image for larger version. 

Name:	Filter.PNG 
Views:	24 
Size:	41.3 KB 
ID:	34663

    I want the user to make their selections. The SUBMIT procedure builds the WHERE clause and the ORDER BY clause. Appears to be working. See below (not based on image above):

    Click image for larger version. 

Name:	Criteria.PNG 
Views:	25 
Size:	7.4 KB 
ID:	34664

    I want the code that displays the filter form to pause and wait for the form to be submitted, and then use the selected filters and sort order to refresh the case list displayed. So I used the code below to display it:

    Code:
            
            Case cCaseFilter ' 11 - Show a form of filter criteria in new window model mode
                DoCmd.OpenForm "CaseFilter", , , , , acDialog
                [Forms]![Main Menu]!subfrmDisplayArea.SourceObject = "CaseList"
    But the code does not pause. It keeps right on going.
    The filter form is designed as pop-up and modal.

    Clearly, I'm not applying something correctly. Any thoughts?
    Thanks in advance.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Note that in the WHERE clause you are missing a closing date delimiter for the end date.
    Code:
    WHERE (Status = 3) and (OpenedDate between (#7/01/2017# and #06/30/2018#)) ORDER BY Institution, Category

    I cannot tell what the variable name is for the WHERE and ORDER BY criteria, and I do not see where you have used it.

    Any chance you would post the dB for analysis?

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The little form with the criteria and order clause is just a regular form? Then you need to change it to a message box, else the code won't wait for user action. It will open the next form as you instructed but without waiting. There are 2 basic ways to halt execution in a case like this; message box and input box, the latter being of no use to you here.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    mredmond13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    Louisiana, USA
    Posts
    16
    Quote Originally Posted by ssanfu View Post
    Note that in the WHERE clause you are missing a closing date delimiter for the end date.
    Code:
    WHERE (Status = 3) and (OpenedDate between (#7/01/2017# and #06/30/2018#)) ORDER BY Institution, Category
    Yeah, I caught the "#" problem and it's already fixed.

    Quote Originally Posted by ssanfu View Post
    I cannot tell what the variable name is for the WHERE and ORDER BY criteria, and I do not see where you have used it.


    This is the 2nd issue I mentioned above. I'll address that in another post dedicated to that.
    I'm really trying to get the code to halt and wait for the FILTER form to be submitted.

  5. #5
    mredmond13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    Louisiana, USA
    Posts
    16
    Quote Originally Posted by Micron View Post
    The little form with the criteria and order clause is just a regular form? Then you need to change it to a message box, else the code won't wait for user action. It will open the next form as you instructed but without waiting. There are 2 basic ways to halt execution in a case like this; message box and input box, the latter being of no use to you here.
    I don't understand this. The form is a regular form and I thought the "acDialog" was supposed to pause the code. Why isn't it?

    Can a message box return a variable, like my WHERE and SORT clauses?

  6. #6
    mredmond13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    Louisiana, USA
    Posts
    16
    Quote Originally Posted by Micron View Post
    The little form with the criteria and order clause is just a regular form? Then you need to change it to a message box, else the code won't wait for user action. It will open the next form as you instructed but without waiting. There are 2 basic ways to halt execution in a case like this; message box and input box, the latter being of no use to you here.
    I think I misunderstood your reply. The little form IS a message box. I put it in, in place of the [Forms]... statement shown in the CODE portion above to show that the code keeps going.

    So the questions remains, what don't I understand about the acDialog term. If it's supposed to stop the code, why isn't it?

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I had to clear the cobwebs out of my old tired brain to recall that the window mode acDialog is supposed to do what you want (stop code execution) and that it sets the form popup and modal properties to True by default. OK, so what can break this functionality is
    a) you open the form from design view or
    b) it is already open when your code attempts to open it.
    In a way, both cases are really the same thing, albeit you would experience one while tinkering with design, but the other from actual use. In either case, it won't work as the form is already open. Could that be the case here due to repeated user actions to build a new filter? Regardless, you should test for the form being open before attempting to open it. Something like
    Code:
    If CurrentProject.Allforms!myFormName.IsLoaded Then
      Docmd.Close Forms!myFormName
      Docmd.Open Forms!myFormName
    Else
    ...
    If the form being open isn't the case, the entire procedure (or at least the parts that open and close the form) might help if you posted it, or maybe if you posted a compacted/zipped copy of your db - because I ran a test and it works for me.
    Another Edit: just thought of another reason, which is that the modality won't work if the form is opened as a datasheet. That doesn't appear to be the case here; just thought I'd add it for posterity. Continuous form same thing? I don't know.
    Last edited by Micron; 07-07-2018 at 08:33 PM. Reason: edited code

  8. #8
    mredmond13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    Louisiana, USA
    Posts
    16
    Quote Originally Posted by Micron View Post
    I had to clear the cobwebs out of my old tired brain to recall that the window mode acDialog is supposed to do what you want (stop code execution) and that it sets the form popup and modal properties to True by default. OK, so what can break this functionality is
    a) you open the form from design view or
    b) it is already open when your code attempts to open it.
    In a way, both cases are really the same thing, albeit you would experience one while tinkering with design, but the other from actual use. In either case, it won't work as the form is already open. Could that be the case here due to repeated user actions to build a new filter? Regardless, you should test for the form being open before attempting to open it. Something like
    Code:
    If CurrentProject.Allforms!myFormName.IsLoaded Then
      Docmd.Close Forms!myFormName
      Docmd.Open Forms!myFormName
    Else
    ...
    That did it!
    I set a DEBUG WATCH to see if the form was already open and it was. Using your code to make sure the form is closed before trying to open it did the trick.

    Thank you, Micron, for your assistance. And thanks to all who contributed to the conversation.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Glad you solved it! Thanks for flagging this as solved. Good luck going forward.

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

Similar Threads

  1. acDialog issue
    By ShostyFan in forum Programming
    Replies: 6
    Last Post: 12-06-2015, 05:23 PM
  2. acDialog
    By ShostyFan in forum Programming
    Replies: 5
    Last Post: 10-03-2015, 06:39 PM
  3. Pausing my Macro??
    By Michael T in forum Access
    Replies: 2
    Last Post: 12-02-2011, 06:58 PM
  4. Pausing OpenReport
    By EES in forum Reports
    Replies: 5
    Last Post: 06-15-2011, 05:30 PM
  5. Pausing a Macro
    By Rick West in forum Programming
    Replies: 0
    Last Post: 03-17-2010, 10:29 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