Results 1 to 7 of 7
  1. #1
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188

    Macro will not close query

    Attached is a test MS Access database. I had to ZIP it because it's over 500K in size.


    Run Macro 1


    Goal: If there are any duped invoice numbers in table [TempOrderImport], at end of macro, the query: qry_Count_TempOrderImport_InvNo should remain open and showing the duped invoice number(s).


    For testing, remove the dupe invoice number: 658275


    Now run Macro 1 again. query: qry_Count_TempOrderImport_InvNo should be closed because there are no duped invoice numbers. Why can't I get the Macro to close query: qry_Count_TempOrderImport_InvNo ..?


    In Macro 2 I removed the conditional statement and the Macro will close the query without issue.


    For whatever reason, Macro 1 will not close the query when it's under a conditional statement. Why?



    Thanks!
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    are you using docmd.close?

  3. #3
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    No. I'm using a macro with CloseWindow function. Attached is a screenshot.

    thanks!
    Attached Thumbnails Attached Thumbnails S1.jpg  

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    In my experience, very few of those here that offer advice, use macros. Generally, we prefer to use VBA code, so our experience with macros is limited.
    However, I notice that you are using the following expression in your If/Then:
    Code:
    IsNull([Forms]![frmCount MultLine Import Orders]![InvNoCount])=False
    Perhaps that should be:
    Code:
    Not IsNull([Forms]![frmCount MultLine Import Orders]![InvNoCount])
    Later you use:
    Code:
    IsNull([Forms]![frmCount MultLine Import Orders]![InvNoCount])=True
    Perhaps that should be:
    Code:
    IsNull([Forms]![frmCount MultLine Import Orders]![InvNoCount])
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    Thanks for the suggestions. I got the same results.

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Try this. No need to use a form. No need to open the query if it's empty.

    Click image for larger version. 

Name:	macro1.png 
Views:	15 
Size:	10.0 KB 
ID:	41082

  7. #7
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    DCount, Wow! Well, that was incredibly useful. That will come in handy for many processes.

    Thank you! Much appreciated!

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

Similar Threads

  1. Replies: 1
    Last Post: 11-28-2017, 07:28 AM
  2. Macro - Close Form
    By Irish_cubflyer in forum Forms
    Replies: 1
    Last Post: 08-26-2014, 04:45 PM
  3. Replies: 4
    Last Post: 01-31-2014, 11:47 AM
  4. Replies: 2
    Last Post: 04-19-2012, 12:53 PM
  5. Replies: 0
    Last Post: 08-25-2008, 12:17 PM

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