database automation using vba … automation using vba (advanced microsoft access, ... activex data...

26
DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Database Program: Microsoft Access Series Instructor: Michael Kremer, Ph.D. Technology & Information Management Section 8

Upload: ngolien

Post on 05-Apr-2018

268 views

Category:

Documents


3 download

TRANSCRIPT

DATABASE AUTOMATION USING VBA

(ADVANCED MICROSOFT ACCESS, X405.6)

Database Program: Microsoft Access Series

Instructor: Michael Kremer, Ph.D.Technology & Information Management

Section 8

AGENDA

13. Updating Data Using DAO

14. ActiveX Data Objects (ADO)

Updating Data Using DAO

13.

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.

13.3 UPDATING RECORDS USING DAO

240

13.3 UPDATING RECORDS USING DAO

241

13.3 UPDATING RECORDS USING DAO

242

13.3 UPDATING RECORDS USING DAO

243

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

13.3 UPDATING RECORDS USING DAO

245

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

13.4 BOOKMARKS/RECORDSETCLONE OBJECTS

247

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

13.4 BOOKMARKS/RECORDSETCLONE OBJECTS

249

13.4 BOOKMARKS/RECORDSETCLONE OBJECTS

250

ActiveX Data Objects (ADO)

14.

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

14.2 PROGRAMMING USING ADO

253

14.2 PROGRAMMING USING ADO

254

14.2 PROGRAMMING USING ADO

255

14.2 PROGRAMMING USING ADO

256