Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objects in Access zGeneral Access objects zData access objects (DAO) yused for data management xdata definition xdata manipulation yused only in code modules.

Similar presentations


Presentation on theme: "Objects in Access zGeneral Access objects zData access objects (DAO) yused for data management xdata definition xdata manipulation yused only in code modules."— Presentation transcript:

1 Objects in Access zGeneral Access objects zData access objects (DAO) yused for data management xdata definition xdata manipulation yused only in code modules

2 Commonly Used Data Access Objects

3

4 Using DAO zUsing the current database  declare an object variable of type Database  use the CurrentDb function to store a reference to the current database yexample Dim dbs As Database Set dbs = CurrentDb( )

5 Using DAO zLooping through collections  uses For Each statement, similar to a For Next loop yexample Dim dbs As Database Dim conTest As Container Set dbs = CurrentDb() For Each conTest In dbs.Containers Debug.Print “Container: “; conTest.Name Next

6 Using DAO  Recordsets yrecords belonging to a table or query ymost commonly used types xtable-type xdynaset-type xsnapshot-type

7 Using DAO  Table-type recordsets  default type for any recordset object ycan use indexes to speed up the process of searching for records yexample Dim rec As Recordset Set rec = db.OpenRecordset(“Students”)

8 Using DAO  Dynaset-type recordsets ycan contain a table or the result of a query ycan be edited and the results will be reflected in the underlying tables  useful if the recordset object is very large yexample Set rec = db.OpenRecordset(“Students”, dbOpenDynaset)

9 Using DAO  Snapshot-type ynot updateable yexample Set rec = db.OpenRecordset(“Students”, dbOpenSnapshot)

10 Using DAO Moving through recordsets

11 Using DAO  RecordsetClone method yalternative to OpenRecordset method ycreates copy of recordset that can be manipulated independently of the form’s recordset  Bookmark property ywhat Access uses instead of record numbers ystored as an array of bytes yused to synchronize recordset objects which are clones of each other

12 Using DAO  Finding records in table-type recordsets  Seek method used with indexed fields xselect indexed field to search on xspecify search criteria xexample rec.Index = “Price” rec.Seek “=“, curPrice

13 Using DAO zFinding records in dynasets and snapshots  Find method  Works on non-indexed fields for all types of recordsets yFour methods xFindFirst xFindLast xFindNext xFindPrevious

14 Using DAO Methods to edit recordsets

15 Using DAO  Editing field values in a recordset yexample rec.Edit rec!strField = NewValue rec.Update

16 Using DAO  With … End With ylogic structure often used with DAOs, but can be used with controls and collections


Download ppt "Objects in Access zGeneral Access objects zData access objects (DAO) yused for data management xdata definition xdata manipulation yused only in code modules."

Similar presentations


Ads by Google