Results 1 to 3 of 3
  1. #1
    bfont is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2015
    Posts
    5

    DoCmd Close Query Not Working

    Hello,



    I have the following code behind a command button on a PopUp form to open a report. The issue is that it also opens a query. I only want the report to open not the query. Can someone tell me what I have done wrong in the code below. Thank you for your help.

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryRptErrors" 'Make Table Query
    DoCmd.OpenQuery "qryCountOfLists" 'Make Table Query
    DoCmd.OpenQuery "qryTotalLists" 'Select Query

    DoCmd.Close acQuery, "qryTotalLists"
    DoCmd.OpenReport "Error Detail Report", acViewPreview
    DoCmd.SetWarnings True
    DoCmd.Close acForm, "PopUp Form"

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Why open it just to close it?
    Just do: docmd.close

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryRptErrors" 'Make Table Query
    DoCmd.OpenQuery "qryCountOfLists" 'Make Table Query
    'DoCmd.OpenQuery "qryTotalLists" 'Select Query

    'DoCmd.Close acQuery, "qryTotalLists"
    DoCmd.OpenReport "Error Detail Report", acViewPreview

    DoCmd.SetWarnings True
    DoCmd.Close acForm, "PopUp Form"
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. VBA code after DoCmd.Close acForm
    By Miles R in forum Forms
    Replies: 9
    Last Post: 04-11-2020, 03:28 PM
  2. DoCmd.Close not working as expected
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 12-07-2016, 12:31 AM
  3. DoCmd.Close Not Working
    By kdbailey in forum Access
    Replies: 6
    Last Post: 12-11-2013, 07:35 PM
  4. DoCmd.Close OpenArgs NOT WORKING
    By clchris_80 in forum Access
    Replies: 1
    Last Post: 01-19-2013, 09:07 PM
  5. docmd.runsql not working
    By Rameez in forum Programming
    Replies: 3
    Last Post: 08-07-2009, 10:07 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