Access VBA Macro Programming

(Joao Candeias) #1
by using theCreateObjectmethod. This is exactly the same as if you had opened Access
directly and chosen a blank database.
Next, theoRSetobject is set to point to your sample table “MyTable”. This is the same as
if you had double-clicked the table name in Access and opened it as a data sheet. A new
record is added and the field MyText is set to “Test String”. Notice that an exclamation mark
is used instead of a dot.
The recordset is then updated and closed and the two objects are set to Nothing to release
memory.
As explained previously, it is very important to be sure to properly close and set to
Nothing any objects created within VBA code. Otherwise, the memory consumed is left
hanging and is unable to be used by other applications later. This can cause problems for
users when they exit your application, because an application was not properly terminated
and is holding memory that may be needed.
I hope this has given you a taste of the immense power of the VBA language and how you
can manipulate other Microsoft applications from within it.

228 Microsoft Access 2010 VBA Macro Programming


Figure 17-3 Selecting the Access Library file
Free download pdf