DATABASE AUTOMATION USING VBA … AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, ... ActiveX Data...
Transcript of DATABASE AUTOMATION USING VBA … AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, ... ActiveX Data...
DATABASE AUTOMATION USING VBA
(ADVANCED MICROSOFT ACCESS, X405.6)
Database Program: Microsoft Access Series
Instructor: Michael Kremer, Ph.D.Technology & Information Management
Section 8
Perform data updates by first issuing the Edit method.
Once updates are completed, use the Update method to save the
changes.
But before updating records, you need to navigate to a specific
record, either use seek or find methods.
13.1 OVERVIEW OF UPDATING DATA
235
Seek method is based on an index.
Can only be used on a table-type recordset.
13.2 FINDING RECORDS
236
Find method works differently, scans entire recordset to find data
(rather than an index).
criteria is the where clause of a SQL statement as a string
parameter.
13.2 FINDING RECORDS
237
Advantage is Find method can be used on all recordset types.
Drawback is that is most likely slower.
13.2 FINDING RECORDS
238
13.3 UPDATING RECORDS USING DAO
239
Updates can only be performed on table-type and dynaset types.
Steps to perform an update:
Go to the desired record (using seek of find method)
Use the Edit method to prepare the record for editing.
Make changes to the record.
Use the Update method to save the changes.
To delete records, use the Delete method.
There is no Update method, the delete takes place immediately.
Changes are not saved if Update method is not issued.
13.3 UPDATING RECORDS USING DAO
244
Bookmark is a special marker in recordset object.
It allows you to mark a position in your recordset and quickly return
to it without using seek or find.
You store a bookmark by
reading the recordset’s Bookmark into a variant variable.
You set a bookmark for a recordset by assigning the stored value to
the recordset’s bookmark.
13.4 BOOKMARKS/RECORDSETCLONE OBJECTS
246
Clone is a method of a recordset, whereas RecordsetClone is a
property of an Access form.
The concepts is the same, they create a copy of the original
recordset.
Why clone? You can navigate within the cloned recordset without
affecting the original
recordset.
13.4 BOOKMARKS/RECORDSETCLONE OBJECTS
248
ADO is universal data access method, not only for Access!
ADO is independent of the data source, it is not tailored towards a
specific product.
ActiveX Objects 2.5 Library (ADODB): This library is the main library
used for data manipulation.
ADO Ext. 2.5 for DDL and Security (ADOX): This library contains
data definition elements and security model.
Jet and Replication Objects 2.5 (JRO): This library contains the Jet
and Replication objects.
14.1 OVERVIEW OF ADO
251
Connection Object:
Represents an open connection to a data source. This is the main
object to reference data in database tables.
Command Object:
Represents specific commands to execute against the data source,
such as running a query.
Recordset Object:
This object is very similar to the recordset object in DAO. It
represents data from a base table or the result of an executed
command.
Implicit vs. Explicit connection
14.1 OVERVIEW OF ADO
252