Results 1 to 4 of 4
  1. #1
    roaftech is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2012
    Location
    Romania
    Posts
    65

    Open vba window causes closure error

    Summary: Access crashes if I close the application whilst the vba window is open.


    Context: My databases utilise the native switchboard form, recoded as required. They have an "exit database" button which is coded as "Exit Application", as per the inbuilt switchboard manager. I have three such front-ends, each linked to the same _be data tables.
    In each case, the "exit database" routine works as it should - except when the vba window is open. Then Access crashes on exit and I get the "MSAccess has encountered a problem and needs to close error". Once I have agreed to send the error report (more out of obstinacy rather than in hope), Access restarts as normal.
    Question: Is there some additional code that can ensure that the vba window is closed first?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    I would be surprised if having the vba window open is the reason for the problem. what is the code behind the 'exit database button'

    I believe the code to close the vba window is
    Application.VBE.MainWindow.Visible = False

  3. #3
    roaftech is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2012
    Location
    Romania
    Posts
    65
    Hi Ajax, thanks for the prompt response
    I have observed this behaviour for some period of time and it does seem to act consistently. I did wonder whether there was some unsaved module or syntax error in the code but I cannot see any evidence for this. The exit button is coded as "Exit Application" as supplied by the switchboard manager.

    The switchboard table contains the following two (relevant) entries:
    SwitchboardID ItemNumber ItemText Command Argument
    1 1 EXIT DATABASE 1 9

    SwitchboardID ItemNumber ItemText Command Argument
    9 0 Exit Options 0
    9 1 Return to main menu 1 1
    9 2 IESIRE - Close database 6

    Then, looking at the vba for the switchboard form, Command 6 is shown as
    Code:
    Const conCmdExitApplication = 6
    which then calls
    Code:
            ' Exit the application.
            Case conCmdExitApplication
                Application.Quit acQuitPrompt
                'CloseCurrentDatabase
    I'll, add in your code snippet and report back.

    Many thanks

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    your code does not look right

    I would expect

    Select Case conCmdExitApplication
    Case 6
    Application.Quit acQuitPrompt
    'CloseCurrentDatabase
    end select

    an since you have declared

    Const conCmdExitApplication = 6

    you don't even need the case statement

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

Similar Threads

  1. Automatic query closure
    By elamadon0228 in forum Queries
    Replies: 2
    Last Post: 10-15-2016, 08:43 PM
  2. Replies: 3
    Last Post: 10-23-2013, 08:11 AM
  3. How to open form in a same window
    By sanchez in forum Forms
    Replies: 11
    Last Post: 08-27-2013, 03:53 AM
  4. Different reports open in same window
    By detjo in forum Reports
    Replies: 1
    Last Post: 02-28-2012, 03:35 PM
  5. Open Outlook window but don't send
    By Paul Taylor in forum Access
    Replies: 2
    Last Post: 04-07-2011, 11:51 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