Access saying database already open

I am trying to run a macro in another database from the database I'm currently in.  The code I'm using is below.  When I run this code, I get an error 7866 (db opened exclusively or doesn't exist).  I've checked multiple times to make sure the db exists and also to check that no one is in the db when this code runs.  There is no ldb when I run the code but I consistently get this error.  I can manually go into the other database and run the macro with no problem.

    Set acApp = CreateObject("Access.Application")
    With acApp
       .Visible = False ' Just not show it.
       .OpenCurrentDatabase strDBName
       .DoCmd.RunMacro strMacroName, 1, 1
    End With
    acApp.CloseCurrentDatabase
    acApp.Quit
    Set acApp = Nothing
msanzenbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jmantha709Commented:
Hi msanzenb,

> .OpenCurrentDatabase strDBName
I'm guessing that's the line that it fails on ?

What is in strDBName ?
msanzenbAuthor Commented:
This is what's in strDBName:
\\kmater01\shared\Public\BSS\DM\InternalProcesses\Reading_Processes\MM_Renewals_Pending\RDG_RN_MMPending.mdb
jmantha709Commented:
Try locally something like :

C:\test.mdb

Just to see if it makes a difference...
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

msanzenbAuthor Commented:
This same code runs macros in other databases with no problem...it's a universally used function
jmantha709Commented:
Sure, but my suggestion is actually to verify if it's a problem with that particular path...
jmantha709Commented:
Can you read/write in that folder ?

Is the file set as read-only ?
jmantha709Commented:
Try this :

msgbox DIR(strDBName)
 Set acApp = CreateObject("Access.Application")
    With acApp
       .Visible = False ' Just not show it.
       .OpenCurrentDatabase strDBName
       .DoCmd.RunMacro strMacroName, 1, 1
    End With
    acApp.CloseCurrentDatabase
    acApp.Quit
    Set acApp = Nothing

What does the messagebox says ?
msanzenbAuthor Commented:
The messagebox was blank
jmantha709Commented:
msanzenb,

There's your problem...

If the file was succesfully located you would get the name of the file.  Blank means it didn't find it.

Check your path and syntax very carefully...
msanzenbAuthor Commented:
It's so strange because I can actually navigate to the file and if I paste the path into a windows explorer window it finds it...is there some setting on the folder or file that could be causing this?
GRayLCommented:
Please post the total line where you load strDBName.  It should look something like:

strDBName = "\\kmater01\shared\Public\BSS\DM\InternalProcesses\Reading_Processes\MM_Renewals_Pending\RDG_RN_MMPending.mdb"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmantha709Commented:
Yes...

And what about this:

msgbox strDBName
 Set acApp = CreateObject("Access.Application")
    With acApp
       .Visible = False ' Just not show it.
       .OpenCurrentDatabase strDBName
       .DoCmd.RunMacro strMacroName, 1, 1
    End With
    acApp.CloseCurrentDatabase
    acApp.Quit
    Set acApp = Nothing
msanzenbAuthor Commented:
Putting the msgbox on strdbname results in:
\\kmater01\shared\Public\BSS\DM\InternalProcesses\Reading_Processes\MM_Renewals_Pending\RDG_RN_MMPending.mdb

Here's the line where I load strdbname:
strDBPath = "\\kmater01\shared\Public\BSS\DM\InternalProcesses\Reading_Processes\MM_Renewals_Pending\RDG_RN_MMPending.mdb"

jmantha709Commented:
To test, try to map a network drive and use that path instead...

Ex:  z:\...\RDG_RN_MMPending.mdb
msanzenbAuthor Commented:
That network drive is actually mapped and I tried using the drive letter but received the same result
GRayLCommented:
If you are familiar with the Immediate Pane, key Ctl-G or Alt-F11, and type:

strDBPath = "\\kmater01\shared\Public\BSS\DM\InternalProcesses\Reading_Processes\MM_Renewals_Pending\RDG_RN_MMPending.mdb"
application.opencurrentdatabase strDBPath

Your mdb should switch to PDG_RN_MMPending.  If it doesn't, there is something wrong with the path and/or filename.
GRayLCommented:
Or that machine does not have access to that file.
GRayLCommented:
Make sure you do not have more than one instance of Access running on your machine at a time and none of them has that mdb already open.  That will also trigger that message.
msanzenbAuthor Commented:
I figured out what it was and I feel incredibly dumb....I had a space at the beginning of my path string.  So, thank you so much for all your help..I'm going to split the points to be fair.  Thanks!!!
jmantha709Commented:
Glad you found your problem !!  It's a mistake we all do sometime, don't worry about it ;)
GRayLCommented:
Thanks , and  goodluck with   odd ball     spaces ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.