PDA

View Full Version : Solved: Error 2046:



nepotist
05-29-2013, 01:29 PM
Hello,

I am trying to access a access database through a third party application. The functionality that I seek to modify is that when the user click on a button in the third party application, It would open the access file, delete a query , create a query and run it.

I am running in to Error 2046 which based on my research says that it occurs because the access application is not active when the code is called.

The code that I have currently is :

If Not FileLocked(strDBName) Then ' This condition is added to prevent from multiple copies of access to be opened.
objAccess.OpenCurrentDatabase strDBName, True
End If


objAccess.DoCmd.DeleteObject 1, "qryInfoLetter" ' This is where the error triggers


This code runs fine when the access file is closed. But causes problems when the access file is open.

Please help!

Thank you
Vinod

nepotist
05-30-2013, 06:34 AM
I am missing something simple but cant not figure out what that is.

To give some background on the situation:

Every time the user tries to create a report using the third party application a copy of access database file is opened and report is generated. I am trying to avoid this multiple copies of access files.

So I am checking if the access file is locked. If it not locked it would open the access file and update the query and run the report (This works fine with the current code as the access is set to foucs). But when the file is locked, I am trying to work with the copy that is already open.

The question is how do I make the currently open copy to set focus and modify the query and run the report.

I hope this information would help you guys to help me.

Thank you for your time.

nepotist
05-31-2013, 11:38 AM
This issue is solved:

I could not get it the way I want it but find a different approach.

Thanks to everyone for trying to help me.