|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Hi, all
I am automating Access 2003 (Server) from another Access 2003 DB (Client).
Depending upon the existence of some objects in the Server DB, the Client VBA will receive the error:
"-2147417851 - Automation error The server threw an exception."
I have looked around, and see that this error has cropped up in discussions before. My error handler checks for this error code, and resumes succesfully.
The issue I am finding difficult to handle is that if the server throws an exception, then the process of closing the server fails silently at the end of the client function, leaving an instance of MSACCESS.EXE running in memory, but not visible - even if the server is made visible when it is being used!
The code is:
Set oAccess = New Access.Application oAccess.OpenCurrentDatabase "C:\Test.mdb"
' do some automation things here.... ' cause the "-2147417851 - Automation error. The server threw an exception."
oAccess.CloseCurrentDatabase oAccess.Quit Set oAccess = Nothing ' <-- after "-2147417851 - Automation error - this does not end the MSACCESS Server process.
My question is:
Is there a way to ensure the server instance is properly closed?
|
|
Access won't close unless it can release all of it's memory/resources. If it looses track of an object, it won't be able to release it, and Access won't close.
Either a) don't do that. Find what is throwing the exception, and fix it.
or
b) live with it
or
c) Find a Windows API that kills processes. I think syscmd(602) returns a process number. Killing the process won't release the resource that Access lost, and you will have a resource leak of some kind.
(david)
"Geoff" <NoSpamEmailReversed_nesneroscg[ at ]bigpond.com> wrote in message news:OekGxcD5FHA.2888[ at ]tk2msftngp13.phx.gbl...
[Quoted Text] > Hi, all > > I am automating Access 2003 (Server) from another Access 2003 DB (Client). > > Depending upon the existence of some objects in the Server DB, the Client > VBA will receive the error: > > "-2147417851 - Automation error > The server threw an exception." > > I have looked around, and see that this error has cropped up in
discussions > before. > My error handler checks for this error code, and resumes succesfully. > > The issue I am finding difficult to handle is that if the server throws an > exception, then the process of closing the server fails silently at the end > of the client function, leaving an instance of MSACCESS.EXE running in > memory, but not visible - even if the server is made visible when it is > being used! > > The code is: > > Set oAccess = New Access.Application > oAccess.OpenCurrentDatabase "C:\Test.mdb" > > ' do some automation things here.... > ' cause the "-2147417851 - Automation error. The server threw an > exception." > > oAccess.CloseCurrentDatabase > oAccess.Quit > Set oAccess = Nothing ' <-- after "-2147417851 - Automation error - this > does not end the MSACCESS Server process. > > My question is: > > Is there a way to ensure the server instance is properly closed? > > >
|
|
Maybe not the cause of your problem, but, there is an article somewhere in the MS KB which recommends using createobject (not the 'new' keyword) to instantiate new objects. I could possibly find that article again if I had to. So try:
set oAccess = createobject ("access.application")
& see if that helps.
Also, precisely what actions cause the automation error?
Are you sure that one or both database do not have a missing reference (tools:references)?
HTH, TC
|
|
Thanks, David,
(Had a few days of being too busy to check back...) I found some example code that is designed to terminate an application. I am sure it works, but it causes an extra automation error, and access crashes 'visibly'.
Given that the function causing the exception is internal to Access (2003), and that I now know some of the reason(s) why an exception is generated, I will approach the problem from a different perspective - since I don't intend to have to live with such a messy outcome.
Finally, FYI, I was working with the ObjectDependencies functionality - its good except for these automation errors!.
Geoff <david[ at ]epsomdotcomdotau> wrote in message news:OgnjMAF5FHA.2092[ at ]TK2MSFTNGP12.phx.gbl...
[Quoted Text] > Access won't close unless it can release all of it's memory/resources. > If it looses track of an object, it won't be able to release it, and > Access > won't close. > > Either > a) don't do that. Find what is throwing the exception, and fix it. > > or > > b) live with it > > or > > c) Find a Windows API that kills processes. I think syscmd(602) returns a > process number. > Killing the process won't release the resource that Access lost, and you > will have a resource leak of some kind. > > (david) > > "Geoff" <NoSpamEmailReversed_nesneroscg[ at ]bigpond.com> wrote in message > news:OekGxcD5FHA.2888[ at ]tk2msftngp13.phx.gbl... >> Hi, all >> >> I am automating Access 2003 (Server) from another Access 2003 DB >> (Client). >> >> Depending upon the existence of some objects in the Server DB, the Client >> VBA will receive the error: >> >> "-2147417851 - Automation error >> The server threw an exception." >> >> I have looked around, and see that this error has cropped up in > discussions >> before. >> My error handler checks for this error code, and resumes succesfully. >> >> The issue I am finding difficult to handle is that if the server throws >> an >> exception, then the process of closing the server fails silently at the > end >> of the client function, leaving an instance of MSACCESS.EXE running in >> memory, but not visible - even if the server is made visible when it is >> being used! >> >> The code is: >> >> Set oAccess = New Access.Application >> oAccess.OpenCurrentDatabase "C:\Test.mdb" >> >> ' do some automation things here.... >> ' cause the "-2147417851 - Automation error. The server threw an >> exception." >> >> oAccess.CloseCurrentDatabase >> oAccess.Quit >> Set oAccess = Nothing ' <-- after "-2147417851 - Automation error - > this >> does not end the MSACCESS Server process. >> >> My question is: >> >> Is there a way to ensure the server instance is properly closed? >> >> >> > >
|
|
HI, TC and thanks,
(Had a few days of being too busy to check back...)
Tried the createojbject - no difference. No missing references.
Finally, FYI, I was working with the ObjectDependencies functionality - its good except for these automation errors!.
Geoff "TC" <aatcbbtccctc[ at ]yahoo.com> wrote in message news:1131498622.065836.100760[ at ]g43g2000cwa.googlegroups.com...
[Quoted Text] > Maybe not the cause of your problem, but, there is an article somewhere > in the MS KB which recommends using createobject (not the 'new' > keyword) to instantiate new objects. I could possibly find that article > again if I had to. So try: > > set oAccess = createobject ("access.application") > > & see if that helps. > > Also, precisely what actions cause the automation error? > > Are you sure that one or both database do not have a missing reference > (tools:references)? > > HTH, > TC >
|
|
Show us the actual line of code that causes the error.
TC
|
|
|