Opening one DB from another DB

G

Guest

I have 2 databses: #1 is the main processing db and is split and #2 compacts
and backs up the FE and BE of #1. When I try to open #2 from # 1, Access
crashes. To determine the problem I created two small dbs with 1 forms each.
On the first, I added a button with the following code:


Option Compare Database
Option Explicit
Dim appAccess As Access.Application

Private Sub cmdGo_Click()
On Error GoTo Err_cmdGo_Click

Dim strDB As String

strDB = "C:\Auto\Second.mdb"
Set appAccess = _
CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strDB
appAccess.DoCmd.OpenForm "frmMain"

Exit_cmdGo_Click:
Exit Sub

Err_cmdGo_Click:
MsgBox "Error occurred " & Chr(10) & Chr(13) & Err.Description & _
Chr(10) & Chr(13) & "Error number:" & Err.Number
Resume Exit_cmdGo_Click

End Sub

This code consistently crashes on the line:

appAccess.OpenCurrentDatabase strDB

It does not enter the error trap but pops up the following:

"Microsoft Office Access has encountered a problem and needs to close. We
are sorry for the inconvenience." , backs up and repairs the db and sends (or
not) a report to Microsoft.

I also tried to do the same process using the command button wizard which
uses the Shell command but the results were the same. I am running Windows XP
with Access XP (2002 - 2003).

Any suggestions would be appreciated!
 
G

Guest

If #1 DB is still open and been used you can't perform compact on it, try to
copy it first and then perform the compact on the copy mdb.
 
G

Guest

I am actually compacting and backing up DB #1 from DB #2. What I would like
to to is:

1. Open DB #2 from DB #1
2. Close DB #2
3. Allow the user to compact and or back up db #1
4. When DB #2 is closed, DB # 1 re-opens

After doing some research, I found that this should be easy enough to do but
I seem to be stuck on step #1 - open db#2 from db #1 - as Access keeps
crashing on the line of code that actually opens db#2:

appAccess.OpenCurrentDatabase strDB

So... I'm still at square 1 (too many 1's and 2's - I'm getting confused!)
 
G

Guest

To open DB2 and close Db1 you can use

Function aaaaaa()
Dim x
x = Shell("C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
c:\FileLocation\FileName") ' check the path for tour msaccess.exe
Application.Quit
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top