I have an Excel template with some macros, which is executing different queries in an Access database stored on a network shared drive.
The first macro creates a table in the Access database based on a linked table. It has always worked fine, but suddenly one of my colleagues gets this error:
Run-time error '2501':
OpenQuery-handling was cancelled.
I then click debug and I can see the vba script stops, when it's trying to run this part of the script.
'Run Query
.DoCmd.OpenQuery ("q_tblUdtræk2")
My colleague is having no trouble opening the Access database and run the queries. He only gets the error, when he tries to execute the macros in the Excel template. It works fine for me and a third colleague.
What can I do to solve the problem?
Best regards
Morten
The first macro creates a table in the Access database based on a linked table. It has always worked fine, but suddenly one of my colleagues gets this error:
Run-time error '2501':
OpenQuery-handling was cancelled.
I then click debug and I can see the vba script stops, when it's trying to run this part of the script.
'Run Query
.DoCmd.OpenQuery ("q_tblUdtræk2")
Code:
Global Const sBaseFile As String = "\\rghfi001\region\SAP-REFLEX\System\TabelKilder\dbMDMDubletter.accdb"
Sub GenopfriskMDM()
'Denne forespørgsel opretter en ny tabel i ACCESS. Kataloglinjer i tabel er udtaget ved følgende
'parametre: Åben+Indgående katalog, Købbare og ikke Rigshospitals kontrakt.
Dim AppAcc, AppAccDatabase
Set AppAcc = CreateObject("Access.Application")
Application.DisplayAlerts = False
'Set Database Path & Name
AppAccDatabase = sBaseFile
'AppAccDatabase = "P:\KoncernOkonomi\indkobsafdelingen\ANALYSEAFDELINGEN\ACCESS\MDM Dublet tjek\Prod\dbMDMDubletter.accdb"
With AppAcc
'Open Database
.OpenCurrentDatabase AppAccDatabase
'Run Query
.DoCmd.OpenQuery ("q_tblUdtræk2")
End With
MsgBox "VBA \ MDM data genopfrisket"
End Sub
My colleague is having no trouble opening the Access database and run the queries. He only gets the error, when he tries to execute the macros in the Excel template. It works fine for me and a third colleague.
What can I do to solve the problem?
Best regards
Morten