Friends,
From one database I need to scan the tables another to pick out a certain one and grab its name into a local variable. To do this, I create a workspace and open the database. When I've got what I want, I close the database and the workspace, and set the variables to nothing.
Trouble is, when I proceed further in my code, subsequent routines produce errors, and I get messages telling me I am do not have exclusive access to my database. Is that other workspace still open somehow?
Here is a bit of the code.
Dim wrkJet As Workspace
Dim RawDataDB As DAO.Database
Dim varTbldef As DAO.TableDef
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
' Open Database object from saved Microsoft Jet database
' for exclusive use.
Set RawDataDB = wrkJet.OpenDatabase ("L:\eCommShared\EMarketingDB\ISRawData.mdb")
For Each varTbldef In RawDataDB.TableDefs
‘here I loop through the tables, looking for a specific one that I’ll use later
‘ as the table name in a query
Next varTbldef
'then I close out
RawDataDB.Close
Set RawDataDB = Nothing
wrkJet.Close
Set wrkJet = Nothing
Exit Sub
I am opening a workspace within a workspace, and I feel this is the root of the problem. Your suggestions are welcome.
best,
p
From one database I need to scan the tables another to pick out a certain one and grab its name into a local variable. To do this, I create a workspace and open the database. When I've got what I want, I close the database and the workspace, and set the variables to nothing.
Trouble is, when I proceed further in my code, subsequent routines produce errors, and I get messages telling me I am do not have exclusive access to my database. Is that other workspace still open somehow?
Here is a bit of the code.
Dim wrkJet As Workspace
Dim RawDataDB As DAO.Database
Dim varTbldef As DAO.TableDef
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
' Open Database object from saved Microsoft Jet database
' for exclusive use.
Set RawDataDB = wrkJet.OpenDatabase ("L:\eCommShared\EMarketingDB\ISRawData.mdb")
For Each varTbldef In RawDataDB.TableDefs
‘here I loop through the tables, looking for a specific one that I’ll use later
‘ as the table name in a query
Next varTbldef
'then I close out
RawDataDB.Close
Set RawDataDB = Nothing
wrkJet.Close
Set wrkJet = Nothing
Exit Sub
I am opening a workspace within a workspace, and I feel this is the root of the problem. Your suggestions are welcome.
best,
p