Results 1 to 5 of 5
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    DoCmd.Quit not available

    I have a general module, TMSTextServer Function, that runs 24/7 and services commands received via Twilio log extractions. That all works quite well. Using the term loosely, the "server" is started via an AutoExec macro that runs the following module:


    Code:
    Option Compare Database
    Option Explicit
    
    Public Function ServerFrontGate()
    
    While 1 = 1
    Call TMSTextServer
    If ServerCode = "Stop" Then DoCmd.Quit
    Wend
    
    End Function
    "ServerCode" is global string and is sometimes set to "ReStart" when the server needs to be restarted, while other times there might be a case where the server needs to shut down as can be seen when "ServerCode" has been set to "Stop". I tried putting a DoEvents before the DoCmd.Quit but I stll get a runtime 2046 error.

    Any thoughts as to what might be causing the DoCmd.Quit failure?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The method might be too old for your version. Try Application.Quit?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    How strange, with the change you suggested, the Access window in fact closed but a 2046 error notice remained on my desktop as you see pictured here:
    Click image for larger version. 

Name:	000.jpg 
Views:	9 
Size:	19.7 KB 
ID:	39376
    I can't account for the residual notice?

    NO NO! When I clicked on Debug I was taken to the code and with Run->Reset I was back at the Access window for the DB.

    Maybe put the code in an invisible form and eliminate the AutoExec macro?

  4. #4
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    What is *Call TMSTextServer*? Might be something there prevent the application from quitting.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    As I was beginning to suspect, the AutoExec macro, for reasons unknown to me, didn't like the Quit being run subordinate to itself. I put the "ServerFrontGate" code in the OnActivate event of a blank form and specified it as the opening form of the DB. I can send a "Stop" command to the server and it "quits" as desired.
    Thanks for your thoughts,
    Bill

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

Similar Threads

  1. Replies: 6
    Last Post: 10-05-2018, 05:26 AM
  2. Replies: 2
    Last Post: 09-27-2016, 09:10 PM
  3. Replies: 1
    Last Post: 10-03-2014, 05:14 PM
  4. Query running on DoCmd.Quit?
    By ts_hunter in forum Access
    Replies: 2
    Last Post: 02-06-2014, 10:16 AM
  5. Replies: 1
    Last Post: 02-13-2012, 10:43 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