Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation error in Access 02

Status
Not open for further replies.

Orion45

IS-IT--Management
Feb 6, 2002
155
US
I have two areas of my application that open and access a second .mdb file which is shared across the LAN. This was working great in Access 2000 but fails in Access 02(XP). Through Microsoft's webpage I found that this error (err. no.-2147467259, MS doc no. 286126) is documented but their resolution to the problem does not work. Their answer was simply to ignore the error until the new form has a chance to load. My code is as follows;
Code:
Private Sub cmdSeatingChart_Click()
On Error GoTo Err_cmdSeatingChart_Click
Dim ReadWriteDB As Access.Application
Set ReadWriteDB = GetObject("J:\BEA\AppSeating\SeatingChart_XP.mdb")
ReadWriteDB.Visible = True

Err_cmdSeatingChart_Click:
    If Err.Number = -2147467259 Then
        Resume
    End If
End Sub
Does anyone out there have any experience with this? Any input is appreciated. This is only one of many bugs I've found so far in Access XP. Thanks for the input,
 
You are trying to use automation of open another copy of the Access database at ("J:\BEA\AppSeating\SeatingChart_XP.mdb"). I've not seen automation working like this ever. When trying to instantiate a new object for an Access application it is normally done as follows only when you want it to be opened and visible. This does not generally allow one database to access or use data from another unless built into the automation code.

Dim ReadWriteDB As Access.Application
Set ReadWriteDB = New Access.Application
ReadWriteDB.OpenAccessProject("J:\BEA\AppSeating\SeatingChart_XP.mdb")

If you don't need the user interface and only access the data or whatever you could do something like this.

Dim wsp As DBEngine.Workspace
Dim pdbServer = Database
Set wsp = DBEngine.Workspaces(0)
Set pdbServer = wsp.OpenDatabase(pstrSAppName)

This would allow you to run methods like execute to execute SQL residing on the remote database, CreateRecordsets from data on the remote database, get properties from the database, etc. Actually, anything but see and interact manually.



-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
As explained this does and has been working for users for the past several months now. My main application is in an Access .mde format but I needed a form which could dynamically create and remove controls based on a user's criteria(creating a seating chart). However, modifying a form can only be done in a .mdb so, to allow for this I had to open a form in a second .mdb on the network. The two applications do not need to link or communicate in any way.
In the next few months our company is switching to MS XP products which means the application has to be converted accordingly. When testing this piece of code stopped working in XP and I have been unable to find a good reason why. Sorry if I didn't explain this well enough earlier.
 
I believe if you follow my first recommendation in my previous post your error may disappear. GetObject normally returns an object reference for an object which is open, CreateObject will open the object and return a reference. If GetObject fails the CreateObject is generally used for late binding. I've never used GetObject to directly open a database rather than application. I personally use automation for Excel and Word frequently. The use of the NEW keyword instantiates the object immediately but then would require you to open the database.

This code construct never fails for automation
--------------------------------
Dim xl As Excel.Application
On Error Resume Next
xl = GetObject("Excel.Application")
If Err.Number <> 0 Then
xl = CreateObject(&quot;Excel.Application&quot;)
End If
-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
I tried your suggestion but continue to get the message &quot;Microsoft cannot open this application because it does not exist or, is opened exclusively by another user.&quot; I have made sure the application was closed at runtime and even double checked the target application to make sure that it was not set to open exclusively. The really weird thing is that when I move the module application to a local drive the code executes perfectly. I'm really starting to believe that this is just another bug in XP. Thanks again for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top