In this article we look at how resources occupied by an automation object in MS Access can be released
The process of Automation allows applications to expose objects. This is done by making use of the application’s properties and methods, which can in-turn be used by other applications for creating an instance, as well as controlling it through codes. Automation is increasingly being used by several applications, instead of Dynamic Data Exchange. All application in MS Office Suite support Automation, thus allowing you to create object references in codes for representing other applications. When you manipulate these objects, you will be able to make changes in the referenced applications, as if they are being programmed directly by you.
An application can be called automation supported, when it has an interface that enables the use of automation techniques through the application, for the purpose of communicating with other applications. You will not be able to see the automation enabled interface, but use it by writing VBA code, that gets attached to the interface and then makes use of all the resources which have been provided by the host. Access is used for writing codes for host applications like Word and Excel, which have an automation compliant interface. The code in Access is what will determine the ‘Automation Objects’ connected to the interface. You can thus control Word by making changes in methods and properties of Automation objects.
Releasing Resources by Automation Objects
This can also be termed as closing an automation object instance. When a variable of an automation object has lost scope, it will be closed. However the closing of an out of scope automation object variable does not guarantee the release of all resources that have been taken up by the given object. There is in-fact a very high possibility that the object will continue to exist even after being shut. It is advisable to always close the instance of automation object explicitly, this can be done by setting it to ‘nothing’.
One of the most reliable technique for closing an automation object is a combination of two techniques mentioned below
WordObj.Quit Set WordObj = Nothing
‘Nothing’ is a value that has been reserved exclusively for all object variables which are no more of scope. This value signals VBA that a particular variable is of no more use, and can be released/ closed. Once the VBA has received signal of redundancy of the automation object variable, it will not only close it, but will also make attempts to remove the variable from the memory. This is important because memory leaks in automation are a common phenomenon, and it can be prevented if the variable is removed from the memory itself.
Releasing resources by automation objects is important because if you continue using the variables which are no longer in use, it will not only create confusion, but also occupy space. All of this can be easily prevented if one makes a wise decision and decides to remove the unused variables from the memory. This will not only free up space, but will also make the system as well automation process safer. However despite such efforts you may still encounter Access crashes and a tool that can recover mdb or accdb database is the best way to keep your data safe.
Vivian Stevens is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql recovery and excel recovery software products. For more information visit www.datanumen.com