Code causing Access to unexpectedly Quit

M

Mike Hinde

Wondering if anyone can offer suggestions for overcoming a
problem the code below is currently giving me?

It's a simple little code to switch between 2 databases
that appears to work fine (and indeed DOES work fine
switching between 3 out of 5 databases) but when you start
using forms in the newly opened database, clicking on
forms/running certain bits of code causes Access to close
down for no apparant reason.

All databases work fine when opened individually - only
when opened using this code do the problems occur.

Any ideas as to what is going wrong/what I've done wrong
would be most appreciated??


*****************************************************
Private Sub Box8_Click()
Const strConPathToEMS = "C:\database.mdb"
Dim appAccess As Access.Application

'Open another Access and the required database
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strConPathToEMS
appAccess.Visible = True
appAccess.RunCommand acCmdAppMaximize
appAccess.DoCmd.OpenForm "frmSwitchboard"
appAccess.Forms("frmSwitchboard").SetFocus
'Close calling database
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.Quit
End Sub
***************************************************
 
T

TC

Are you saying that the exact code shown in your post, works with certain
values in strConPathToEMS, and does not work with other values?

When you say that clicking on forms/running certain bits of code causes
Access to close down for no apparant reason, I assume you mean the copy of
Access that is created by the CreateObject call? That copy works ok when you
have used certain values of strConPathToEMS, but cloes down unexpectedly
when you use other values of strConPathToEMS? Does the "calling" copy of
Access close (or not close?) consistently in all cases?

I'm just strying to get a clear picture of what is hapenning, before I
suggest a cause.

TC
 

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