Opening Form in New Workspace

gray

Registered User.
Local time
Today, 13:46
Joined
Mar 19, 2007
Messages
578
Hi

Really sorry to need your help again so soon.... I am utterly befuddled by the syntax and order of actions here!.... I am trying to open a bound form in its own workspace so I can later use Transactions. Every example I've seen has a peice of the puzzle but I just can't quite put it all together. My latest effort, below, fails with "Item Not Found in this Collection" at

Set dbsAddresses = DBEngine.Workspaces("wrkAddresses")

Any advice please?

Code:
Declarations
Private wrkAddresses As DAO.Workspace
Private dbsAddresses As DAO.Database
Private rstAddresses As DAO.Recordset


Private Sub Form_Open(Cancel As Integer)

Set wrkAddresses = CreateWorkspace("NewAddressesWorkspace", "admin", "", dbUseJet)
Workspaces.Append wrkAddresses

Set dbsAddresses = DBEngine.Workspaces("wrkAddresses")
Set rstAddresses = dbsAddresses.OpenRecordset("SELECT * FROM Addresses", dbOpenDynaset)
Set Me.Recordset = rstAddresses

End Sub
 
Hi

I think I have resolved this thanks... for anyone else out there struggling with this here's what worked for me...

Code:
Private wrkAddresses As DAO.Workspace
Private dbsAddresses As DAO.Database
Private rstAddresses As DAO.Recordset    

Private Sub Form_Open(Cancel As Integer)
Dim Extg_DbName As String

Extg_DbName = CurrentDb.Properties(0).Value    
Set wrkAddresses = CreateWorkspace("NewAddressesWorkspace", "admin", "", dbUseJet)
Workspaces.Append wrkAddresses  'in case you need to access it elsewhere
Set dbsAddresses = wrkAddresses.OpenDatabase(Extg_DbName)
Set rstAddresses = dbsAddresses.OpenRecordset("SELECT * FROM Addresses", dbOpenDynaset)
Set Me.Recordset = rstAddresses

Exit Sub

Don't forget to clear them in the Form Unload

rstAddresses.Close
Set rstAddresses = Nothing
wrkAddresses.Close
Set wrkAddresses = Nothing
Set dbsAddresses = Nothing
 
Last edited:

Users who are viewing this thread

Back
Top Bottom