Nope, neither of those helped. Here's an update though.
I've traced this back to the .ldb file which has two occurrences of my machine as having the file open. Essentially, what's happening is that one occurrence is opened when I first open the file and the other occurrence is opened when I run the code.
I decided to start from the beginning of the code and add pieces on until I acheived this second lock in the .ldb.
Fortunately, that didn't take long at all. Here is the code that causes this:
-
Public Function CreateWrkJet()
-
Set wrkjet = CreateWorkspace("Jet1", "Admin", "", dbUseJet)
-
DBEngine.Workspaces.Append wrkjet
-
End Function
For some quick background, this is code I use in basically every interface I build so it's time tested. All of the variables are declared globally in a seperate module.
Creating the new workspace doesn't cause the lock, but appending to the collection does.
What's odd is that I use this same snippet of code in dozens of other projects and have not had the same issue. I even opened those projects up and couldn't reproduce it. So I have the same exact code running in different projects with different actions being taken with respect to the .ldb file.
To further my problem is that any project I start (just test db's), I have this issue. I've taken all of the properties from the projects that it works fine with and set my new db to imitate those, but it's had no effect.
Now, I was able to get this to work by adding a line of code:
-
Public Function CreateWrkJet()
-
Set wrkjet = DBEngine.Workspaces(0)
-
Set wrkjet = CreateWorkspace("Jet1", "Admin", "", dbUseJet)
-
DBEngine.Workspaces.Append wrkjet
-
End Function
It seems that if I initialize the workspace variable in the default workspace first I don't have the issue. So it seems there is something I'm missing with respect to the DBEngine and how it handles locks, database properties, and sharing. Maybe more. Maybe less, I don't know.