Can't open Database

H

Hydra

Sub DisplayTable()

Dim strDB As String

' Initialize string to database path.
Const strConPathToSamples = "C:\Database\" _

strDB = strConPathToSamples & "MSPData2"
' Create new instance of Microsoft Access.

Set appAccess = _
CreateObject("Access.Application")

' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strDB

' Open table.
appAccess.DoCmd.OpenTable "MSPData"

End Sub


This throws an erroe at appAccess.OpenCurrentDatabase strdb which says the
file is missing or opened exclusively by another user.

Sure enough, If I go to explorer and try to open it, it will not open.

But, if I reset the code and then go to explorer and open the file, then it
opens normally.

It is as if the code was setting a lock on the file before it opens.


I have code that deletes the old database and makes a new on from scratch,
filling it with MSP data. All of that works.

But if I just want to open an existing file and append new data, then I
cannot open the file.


?????????????????????????????
 
H

Hydra

And the same code throws the same error operatiing under Excel and calling
Access on my home computer.
 
H

Hydra

This code runs against an MSProject file and creates an Access database. The
Access crowd ouldn't find th eproblem so I though t it might have soething to
do with project.
 
R

Rod Gill

Your code is only executing Access VBA actions: nothing to do with Project.
However, the project file may be corrupt. Try creating a new, blank project
in Access then saving a Project to it using Project 2003 (note 2007 no
longer has this ability). The code can't work unless the mdb file can be
opened manually in Access.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top