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

How to open a new database from an existing database?

Status
Not open for further replies.

siebel2002

Programmer
Oct 8, 2001
102
US
Help, Please!

I have a command button in my access database with the following code for the onclick event. My need is to open the Employees database.

Sub cmdEmployessDatabase_Click()
Dim strPath As String
strPath = "C:\MyFolder\Employees.mdb"
OpenCurrentDatabase strPath
DoCmd.OpenForm "Employees", acNormal
End Sub

I dont see the database opening!! Please help!

 
Try a new Access application object with the file name as a paramater.
definition of 'less behind': "not fully caught up, digging out slowly, one-week delay to "The IT hit the fan."
 
First, your syntax is incorrect. Online help has an example of exactly what you're trying to do.

Second, if you can't get that to work, you may have run into the same problem I had. Access would simply exit upon executing the OpenCurrentDatabase method. I ended up having to put a call into Microsoft. The only solution was reinstalling office.
 
I have used this code behind a couple of option buttons to open another Access application.

Private Sub optOnLine_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

' Open Access project.
pubFilePath = "C:\mydir\remotepubs.adp"
Set pubAppAccess = New Access.Application
pubAppAccess.OpenAccessProject pubFilePath

pubAppAccess.Application.RefreshDatabaseWindow
pubAppAccess.Application.Visible = True
DoCmd.Close

End Sub

Private Sub otpOffLine_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

' Open Access project.
pubFilePath = "C:\mydir\localpubs.adp"
Set pubAppAccess = New Access.Application
pubAppAccess.OpenAccessProject pubFilePath

pubAppAccess.Application.RefreshDatabaseWindow
pubAppAccess.Application.Visible = True
DoCmd.Close

End Sub
 
cmmrfrds is exactly correct. However, just make certain you change the extensions for your file names to .mdb if you are using a Database instead of a Project File.

Good luck!
SATHandle
[thumbsup] definition of 'less behind': "not fully caught up, digging out slowly, one-week delay to "The IT hit the fan."
 
Thanks guys! The line, "appAccess.Visible = True" is what did the trick..

Tahnks again for your responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top