Run time error 7867: database already open

The_Kurgan

Active Member
Joined
Jan 10, 2006
Messages
270
Good day!
I'm running an automation process by which I open Access via Excel, run a macro, then return the data to Excel. This works fine on my computer, but my coworker gets this error when running it on his: "You already have the database open." The db is not open, however. I don't believe this to be a reference issue, as we are both using the same Excel workbook... references will be the same for both of us.

Thoughts/suggestions would be welcome. Thank you in advance!
 
You could run that code, with some minor additions/alterations, from Excel.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Is there a way to bump this thread so it doesn't die here? There has to be a reason it works for me and not for him... a missing DLL or something???
 
Upvote 0
You could try making the DB visible first, just to see what you can see ...

Code:
'run macros
For iter = 1 To bottom_row - 1
If IsEmpty(MyMacro(iter)) = False Then
   Set AccessApp = CreateObject("Access.Application")
   With AccessApp
      .Visible = [COLOR="#FF0000"]True[/COLOR]
      .OpenCurrentDatabase MyAccessPath(iter)
      .DoCmd.RunMacro MyMacro(iter)
      .CloseCurrentDatabase
      .Quit
   End With
   Application.StatusBar = "Running macro: " & MyMacro(iter) & "... "
End If
Next iter

It doesn't sound like the problem per se but I would as a matter of course check the value of the variable too:
Code:
'run macros
For iter = 1 To bottom_row - 1
If IsEmpty(MyMacro(iter)) = False Then
   Set AccessApp = CreateObject("Access.Application")
   With AccessApp
      .Visible = [COLOR="#FF0000"]True[/COLOR]
      [COLOR="#FF0000"]Msgbox MyAccessPath(iter)[/COLOR]
      .OpenCurrentDatabase MyAccessPath(iter)
      .DoCmd.RunMacro MyMacro(iter)
      .CloseCurrentDatabase
      .Quit
   End With
   Application.StatusBar = "Running macro: " & MyMacro(iter) & "... "
End If
Next iter

PS, there's no need to bump threads in the Access forum - there's not enough activity (for now, at any rate), so all the regulars will definitely see your thread every day even if it's not at the top of the list.
 
Last edited:
Upvote 0
Good news! It was cleared up. We did the .Visible = true to watch what was happening and noticed that an Access session was opening, but with a different database. Turns out, he had checked a selection in "Client Settings" to make the last used database open upon opening Access. The error message could have been better worded, so it's no wonder I was thrown-off.

Thanks for all the input!
 
Upvote 0
Thanks for letting us know. That's one I hadn't heard of before ... glad you figured it out.
ξ
 
Upvote 0

Forum statistics

Threads
1,217,376
Messages
6,136,197
Members
449,998
Latest member
jpaul123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top