Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Database 2 from within Database1

Status
Not open for further replies.

Deco1

Programmer
Mar 15, 2002
3
0
0
GB
I'm using VBA within Access. I've got a module in database 2 which runs when the database 2 is opened. When it has finished the database closes down. What I would like to be able to do is to open database 2 from database 1 to run this module, close database 2 and keep database 1 open. I've tried a new procedure(see code below) and when I step through the procedure it appears to be working but nothing actually happens.
Any ideas?????

Cheers

Private Sub Command0_Click()
Dim dbs As Database
Dim dbImport As Database
Dim strdb As String
Dim wrkJet As Workspace

Set dbs = CurrentDb
Set wrkJet = DBEngine.Workspaces(0)

MsgBox "Opening"

strdb = "G:\reinledg\Midnight\697LPC\LPCCashImport.mdb"

Set dbImport = wrkJet.OpenDatabase(strdb)

End Sub
 
Try:

Dim Db as DataBase
Dim Db2 as DataBase

Set Db = CurrentDb()
Set Db2= DBEngine.Workspaces(0).OpenDatabase ("G:\reinledg\Midnight\697LPC\LPCCashImport.mdb")

'The Set statement is all on one line.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top