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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open a second database from within a database 1

Status
Not open for further replies.

hellohello1

Technical User
Jun 30, 2006
110
US
I am using Access 2003 and I'm trying to open a second database from within a database.

I tried this code behind a command button:

Shell ("""" & "c:\Program Files\Microsoft Office\OFFICE11\MSAccess.exe" & """" & " " & """" & sAdhocReport & """")

where sAdhocReport is the full path of my other database.

It works. I'm just looking for two things:
1). Currently, the second database opens, but it doesn't pop up. It stays on the Windows task bar. How can I make the second database to be the focus?

2). I would like the second database to open showing the Reports Window.

Thanks!
 
1) You may try to use the AppActivate instruction
2) Have a look to the /x switch

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV, thanks for writing. I tried AppActivate, but it didn't work:

Dim adhocID As Integer

adhocID = Shell("""" & "c:\Program Files\Microsoft Office\OFFICE11\MSAccess.exe" & """" & " " & """" & sAdhocReport & """")

AppActivate adhocID

Then I did a google search for /x switch but couldn't find anything relevant to my situation.

Thanks,
 
thanks again for writing PHV.

I looked at the website, but still don't get it. I don't need to run a macro, I just want the second Access database to have the focus after it opens, and then show the main reports window.

thanks!

 
Why not by automation?:
Code:
Dim acApp As Access.Application

Sub test()
Set acApp = New Access.Application
acApp.OpenCurrentDatabase "D:\Path\FileName.mdb"
acApp.Visible = True
End Sub
Access application should be declared in module.


combo
 
combo,

thanks for writing.

i can't get your code above to work. it starts to open the second database (I get the security warning from the second database), but then it disappears and it never opens.

thanks,
 
Application object should be declated at module level:
Access Help said:
When the variable pointing to the Application object goes out of scope, the instance of Microsoft Access that it represents closes as well. Therefore, you should declare this variable at the module level.
See in object browser ahd help file the additional parameters of OpenCurrentDatabase method.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top