My concern is that there is a read-write lock in the file I want to connect to because it is being used by an application as shown: Locked MS Access File
When I try to refresh the data connection in MS Excel, these errors/notifications occur because it is unable to make a connection to the MS Access file that is being used:
I am wondering if there is a way for VBA to detect if establishing a data connection has failed. I have no idea how to approach it and the VBA code to refresh the query is shown below:
With ActiveWorkbook.Connections("Query - MS Access File")
.OLEDBConnection.BackgroundQuery = False
.Refresh
End With
The connection string of my Excel data connection to a Access file is shown below:
Provider=Microsoft.ACE.OLEDB.12.0;
User ID=Admin;
Data Source=C:\Users\ACER\Desktop\Test.MDB;
Mode=Share Deny Write;
Extended Properties="";
Jet OLEDB:System database="";
Jet OLEDB:Registry Path="";
Jet OLEDB:Engine Type=5;
Jet OLEDB:Database Locking Mode=0;
Jet OLEDB:Global Partial Bulk Ops=2;
Jet OLEDB:Global Bulk Transactions=1;
Jet OLEDB:New Database Password="";
Jet OLEDB:Create System Database=False;
Jet OLEDB:Encrypt Database=False;
Jet OLEDB:Don't Copy Locale on Compact=False;
Jet OLEDB:Compact Without Replica Repair=False;
Jet OLEDB:SFP=False;
Jet OLEDB:Support Complex Data=False