Access.2007.VBA.Bibl..

(John Hannent) #1
Set cnn = Nothing
End If
End If

Exit Sub

ErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit

End Sub

Data from each record is printed to the Immediate window; the last two records’ data is listed here:


Company ID: Yclept Yarbro
Category: Books
Company Name: Yclept Yarbro

Company ID: ZDExpos
Category: Computer
Company Name: ZDExpos

Record ..........................................................................................................

An ADO Record object represents a set of data, which may be from a recordset or a non-database
source. When working with Access data, the Record object is a single row from a recordset, or a
one-row recordset. There are many specialized uses of Record objects based on non-Access data (in
particular, for working with hierarchical data and displaying it in TreeView controls), but when
working with Access data in VBA code there is no reason to use the Record object, because you can
reference fields as needed on the current record in a recordset without creating a Record object.


Stream ..........................................................................................................

A Stream object represents a stream of data from a text file, XML document, or web page. Because
this object doesn’t work with Access data, it is dealt with in the chapters on working with text files,
specifically Chapters 9 and 17.


Converting DAO Code to ADO Code ................................................................................


If you want to convert your old DAO code to new ADO code — perhaps for consistency with ADO
code working with other types of data, or out of concern that DAO will no longer be supported in
future versions of Access — you can use Table 5.7 as a guideline. Bear in mind that some types of
DAO code can’t be converted to ADO, because they have no equivalent in the ADO object model,
so you will still need to use DAO for Access form recordsets, or creating tables and their fields pro-
grammatically.


Working with Access Data 5

Free download pdf