Access object environment

 

Access Data Project (ADP)

Contains forms, reports, macros, modules, and data access pages which are connected to the back-end database that contains the tables and queries

 

Application object

Open a database

OpenCurrentDatabase method

e.g., DIM AccessApp AS Access.Application

        SET AccessApp = NEW Access.Application

        CONST path = “d:\mgt695\”

        WITH AccessApp

                 .OpenCurrentDatabase path & “622.mdb”

                 .DoCmd.OpenReport “Grade”

         END WITH

Close a currently opened database

Access.Application.CloseCurrentDatabase

Open a form

DoCmd.OpenForm form_name

 

The AllForms collection of the CurrentProject object comprises all the saved forms.

The Forms collection comprises only the forms currently running in memory
Access Data Environment

MSDE

MicroSoft Database Engine

Contains tables and queries

Replaced by SQL Server Desktop Engine

ADO

ActiveX Data Objects

New data access technology: non-hierarchical

DAO

Data Access Objects

Pre-2000 data access technology

 

ADO (ActiveX Data Objects) Model

 


Connection object

Connection object

Defines a session for a user for a data source

Declaring a connection object

DIM c_object_name AS ADODB.Connection

Initiate a new connection object

SET c_object_name = NEW ADODB.Connection

Open the connection

Open method

c_object_name.OPEN connection_string

Connection string

“PROVIDER = Microsoft.Jet.OLEDB.4.0;”

“DATA SOURCE =”

Close the connection

Close method

c_object_name.CLOSE

Destroy the connection object

Set c_object_name = Nothing

 

Recordset object

Recordset object

Defines records as a group

Declaring a recordset object

DIM r_object_name AS ADODB.Recordset

Initiate a new recordset object

SET r_object_name = NEW ADODB.Recordset

Point the recordset object at a set of records

r_object_name.OPEN data_source, CurrentProject.Connection

Data source

Table name, SQL statement, …

Close the recordset

Close method

r_object_name.CLOSE

Destroy the recordset object

Set r_object_name = Nothing

 

Fields collection

Count property

Returns the number of fields in the recordset

r_object_name.FIELDS.COUNT

EOF property

Returns true if the current position is at EOF

r_object_name.EOF

Retrieve data based on the field name

r_object_name!field_name or

r_object_name(“field_name”)

MoveNext method

Moves to the next record in the recordset

r_object_name.MoveNext

AddNew method

Adds a new record

Update

Modifies data in an existing record

Delete

Deletes a record


DAO (Data Access Objects) Model