Consulting

Results 1 to 3 of 3

Thread: Solved: Error 2046:

  1. #1
    VBAX Mentor
    Joined
    Aug 2008
    Posts
    323
    Location

    Solved: Error 2046:

    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 :

    [VBA]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
    [/VBA]

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

    Please help!

    Thank you
    Vinod
    I am a Newbie, soon to be a Guru

  2. #2
    VBAX Mentor
    Joined
    Aug 2008
    Posts
    323
    Location
    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.
    I am a Newbie, soon to be a Guru

  3. #3
    VBAX Mentor
    Joined
    Aug 2008
    Posts
    323
    Location
    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.
    I am a Newbie, soon to be a Guru

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •