OpenDatabase

Randix

Registered User.
Local time
Today, 19:08
Joined
Mar 24, 2001
Messages
56
Access 97; need assistance on OpenDatabase

I have 2 databases, one called "legal" and one called "contract_review". When the user enters "legal", a form comes up which gives the user the option to go to the other database, eg contract_review...i created a button on the form and put the following code, intending to have the current database closed, the other database opened along with a particular form in that database...

Dim wsp As Workspace
Dim mydb As Database
CloseCurrentDatabase
Set wsp = DBEngine.Workspaces(0)
Set mydb = wsp.OpenDatabase("contract_review", , , "OBDC")
DoCmd.OpenForm ("Main_Entry")

The current database does close, but the form in the other database doesn't come up, indeed I'm not even sure at that point the other database is actually opened up...

Any suggestions? Thanks.
 
Hey Randix,

rather open another Access-session and there open that database with DoCmd.OpenForm:

dim oAcc2 AS Access.Application
set oAcc2=createObject(,"Access.Application")
oAcc2.DoCmd.OpenForm(...)

This is the only way starting code in another database.

Mic
 
You may consider setting a reference within the first Db to the second which will enable you to use the forms etc of Db2.

Write a Function in Db2
Function Start_Db2()
docmd.openform myForm
end function

in db1 call the function, e.g.
dim intReturn as integer
intReturn = Application.Run("Db2.Start_Db2")
 
Thanks Keith, I ended up going with MHM's suggestion and just am opening another session even though i really didn't (and don't) want to do that...the opendatabase command still has me stumped cause i don't want to open up another workspace, just use the current one, but can't "afford" to spend any more time struggling with it so just used the second session suggestion...maybe when i'm old and retired i'll spend the last remaining days trying to figure out how to make it work...
 

Users who are viewing this thread

Back
Top Bottom