Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93

    Exiting Access produces error depending how it is started

    I have an application called "MCLAP4". In the Access Options-Current Database-Application Options, I have the "Display Form:" set to "login screen". That is an existing form that works fine. On one of my forms, I have an "Exit" command button. The "On-Click" property of that form is the following VBA code:
    Private Sub Command3_Click()
    DoCmd.Quit acQuitSaveAll

    End Sub

    When I run the application as an application, and I click the "Exit" button, I get the following error: "MCLAP4 cannot find the referenced form 'login screen'.
    When I run the application from design mode, starting from the form "login screen", and then go to the form with the Exit button, and then click that same Exit button, I get no such error, and Access exits cleanly.
    Why does the same code behave differently depending on how Access is run, how can I get it to exit cleanly in application mode, and why is it looking for this form? By the way, I even loaded the form "login screen" in hidden mode and I still got the same symptoms.



    Attached is a screenshot of the error

    Access Error.doc

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Have you tried executing the code when the form "login screen" is open? When you are testing from design mode, try it with that form open.

    Run
    Private Sub Command3_Click()
    DoCmd.Quit acQuitSaveAll

    to see if it has to do with properties of form "login screen"

  3. #3
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    Quote Originally Posted by ItsMe View Post
    Have you tried executing the code when the form "login screen" is open? When you are testing from design mode, try it with that form open.

    Run
    Private Sub Command3_Click()
    DoCmd.Quit acQuitSaveAll

    to see if it has to do with properties of form "login screen"

    But it works fine in Design mode. The error does not appear.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I was trying to decipher what you have tried and what you have not tried. It may not be associated with the autoexec macro and it may be the form's properties, it may be something else. I don't know.

    If, in design mode, the form is open and the code is successful in closing the app. I would suggest adding some code before executing DoCmd.Quit acQuitSaveAll.

    Perhaps some code to close the form login screen. Whatever it is it is probably associated with acQuitSaveAll

  5. #5
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    The form "Login Screen" is not open. I am not running an autoexec macro. When you set the Display Form in Access Options, that's what comes up when you run the app. The login screen is closed shortly after the user login. Again, when the database is in Design Mode and you start with the "Login Screen" form, and after logging in and accessing the form where the Exit button is, when the Exit button is clicked, Access exits without incident. But if I run the database directly, it starts with the same "Login Screen" form, then when the Exit button is clicked, I get the message. The Exit button is on another form, unrelated to "Login Screen".

    Again, I tried loading the "Login Screen" form just before the quit, just for the hell of it:

    Private Sub Command3_Click()
    DoCmd.OpenForm "Login Screen", acNormal, "", "", , acHidden
    DoCmd.Quit acQuitSaveAll

    End Sub

    Same symptom.

    But again opening the database in Design mode, it exits cleanly

  6. #6
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536

  7. #7
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    Quote Originally Posted by alansidman View Post

    alansidman: I do not understand the purpose of the cross-post. I posted the same question in 4 forums in order to try to get an answer as quickly as possible.

  8. #8
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    So far, the best workaround is to forcibly re-open "Login Screen" just before exiting the application. This in my opinion is a weak solution and does not address the root cause. I am still looking for an actual solution.

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Grasshopper, you must first walk on this rice paper before you can use the VBA editor.


    Quote Originally Posted by pledbetter View Post
    But it works fine in Design mode. The error does not appear.
    Quote Originally Posted by pledbetter View Post
    The form "Login Screen" is not open. I am not running an autoexec macro. When you set the Display Form in Access Options, that's what comes up when you run the app. The login screen is closed shortly after the user login. Again, when the database is in Design Mode and you start with the "Login Screen" form, and after logging in and accessing the form where the Exit button is, when the Exit button is clicked, Access exits without incident. But if I run the database directly, it starts with the same "Login Screen" form, then when the Exit button is clicked, I get the message. The Exit button is on another form, unrelated to "Login Screen".

    Again, I tried loading the "Login Screen" form just before the quit, just for the hell of it:

    Private Sub Command3_Click()
    DoCmd.OpenForm "Login Screen", acNormal, "", "", , acHidden
    DoCmd.Quit acQuitSaveAll

    End Sub

    Same symptom.

    But again opening the database in Design mode, it exits cleanly
    Quote Originally Posted by pledbetter View Post
    So far, the best workaround is to forcibly re-open "Login Screen" just before exiting the application. This in my opinion is a weak solution and does not address the root cause. I am still looking for an actual solution.

  10. #10
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    ???????????????

  11. #11
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    The form has to be forcibly re-opened in "Normal" mode. "Hidden" mode gives the same error.

  12. #12
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Let me share with you about crossposting and when you should use it.

    Please read this: http://www.excelfox.com/forum/f25/me...1172/#post5326

  13. #13
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    Quote Originally Posted by alansidman View Post
    Let me share with you about crossposting and when you should use it.

    Please read this: http://www.excelfox.com/forum/f25/me...1172/#post5326
    Yeah my bad on that one. Newbie mistake. I had no idea the "Forum World" was so competitive with its own standards of conduct. I'll try to be more considerate next time.

  14. #14
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    93
    So are we stuck with a workaround without a solution?

  15. #15
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by pledbetter View Post
    So are we stuck with a workaround without a solution?
    The workaround was not suggested as a workaround. It was suggested so I could better understand the behavior of the application.

    Are you asking for my opinion? If not, the answer is already right here in this thread.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-27-2013, 02:17 PM
  2. Replies: 1
    Last Post: 03-22-2013, 09:59 AM
  3. Changing Printers Code produces an error
    By Perceptus in forum Programming
    Replies: 4
    Last Post: 01-15-2013, 08:33 PM
  4. VBA code exiting no error.
    By Jmeyering in forum Programming
    Replies: 1
    Last Post: 11-12-2012, 04:29 PM
  5. exporting text produces a number
    By greend in forum Import/Export Data
    Replies: 0
    Last Post: 07-12-2006, 03:55 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