[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 875
  • Last Modified:

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
0
msanzenb
Asked:
msanzenb
  • 9
  • 7
  • 5
2 Solutions
 
jmantha709Commented:
Hi msanzenb,

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

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

C:\test.mdb

Just to see if it makes a difference...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Is the file set as read-only ?
0
 
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 ?
0
 
msanzenbAuthor Commented:
The messagebox was blank
0
 
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...
0
 
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?
0
 
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"
0
 
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
0
 
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"

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

Ex:  z:\...\RDG_RN_MMPending.mdb
0
 
msanzenbAuthor Commented:
That network drive is actually mapped and I tried using the drive letter but received the same result
0
 
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.
0
 
GRayLCommented:
Or that machine does not have access to that file.
0
 
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.
0
 
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!!!
0
 
jmantha709Commented:
Glad you found your problem !!  It's a mistake we all do sometime, don't worry about it ;)
0
 
GRayLCommented:
Thanks , and  goodluck with   odd ball     spaces ;-)
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 9
  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now