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

Start 2nd Access from within Access 1

Status
Not open for further replies.

lhs24

Technical User
Aug 15, 2000
6
US
I don't know if this can be done, but I want to provide a button for users to be able to start a 2nd session of access opening an 2nd existing database from the current database they are using. I would like the user to return to the original database when finished. I would use one database but the second database has a different set of users that I do not want in the first database.

This is how far I have gotten.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Dim mywrk As DAO.Workspace
Dim mydb As DAO.Database
Dim mydbname As String

mydbname = "P:\Operations\Eng-Ops\PMI Process\PMI System Database\PMI Process Database v4.mdb"

Set mywrk = DBEngine.CreateWorkspace("Testwrkspace", "admin", "")
Set db = DBEngine.OpenDatabase(mydbname)
DoCmd.OpenForm "Start Form", acNormal, , , acFormPropertySettings


Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
 
Look into createobject, getobject and the opencurrentdatabase method of the application object.
 
I had the same issue a week or two ago. The code below will open a new maximized window with the database you specify as the variable 'str' (you have to include the full path name).

Hope it helps...

Option Compare Database
Option Explicit
Dim obj As Object
Private Declare Function ShowWindow Lib "user32" (ByVal _
hwnd As Long, ByVal nCmdShow As Long) As Long

Sub OpenIt(T)

Dim dwReturn As Long
Dim f As Form
Dim str As String

On Error GoTo ErrCatch

Set obj = CreateObject("Access.Application")

obj.Application.Visible = True

dwReturn = ShowWindow(obj.hWndAccessApp, 3)
obj.Application.OpenCurrentDatabase str

Exit Sub

ErrCatch:
MsgBox Err.Number & " - " & Err.description

End Sub
 
Thanks for the Help lameid and Beren1h
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top