Results 1 to 2 of 2
  1. #1
    gameemaster is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2016
    Posts
    23

    AutoExec VBA Code To Not Execute If The Database Is Already Opened by Another User

    Hello,

    I have an excel workbook that has numerous data connections to an Access Database. In order to update the data in excel, on workbook open, I have a code in excel that opens Access and runs action queries via an AutoExec built-in Access Macro. Using only data connections straight to Access doesn't work because I need to run those action queries to update my data at workbook open, so I have to open Access at excel workbook open. However, multiple people use this excel-connected workbook, and when someone else is already in it, the access database will open, when someone else opens the excel report and Access attempts to run the action queries which throws an error. If I didn't have to run those action queries, then I wouldn't be having this issue, and multiple people could open the excel report without error.

    I'm looking to convert the AutoExec built-in Macro to VBA code, and find a way, that the AutoExec macro won't execute if the database is already opened by another user.

    Does anybody have a method for this?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    In your Excel code check for the presence of the .laccdb file (which would indicate Access is already open) and skip opening Access if present.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. autoexec to execute function at startup not working
    By bbxrider in forum Programming
    Replies: 10
    Last Post: 01-12-2019, 05:50 PM
  2. Replies: 1
    Last Post: 06-28-2017, 07:07 AM
  3. Replies: 10
    Last Post: 05-02-2016, 12:19 PM
  4. Replies: 3
    Last Post: 08-26-2015, 09:46 AM
  5. Code needed when Database is Opened
    By Access_Headaches in forum Access
    Replies: 7
    Last Post: 08-13-2010, 01:03 PM

Tags for this Thread

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