>
rstPublishers!PubID = 99 rstPublishers("PubID") = 99 rstPublishers.Fields("PubID").Value = 99When you create a Recordset object, the current record is positioned to the first record if there are any records. If there are no records, the RecordCount property setting is 0, and the BOF and EOF property settings are True. You can use the MoveNext, MovePrevious, MoveFirst, and MoveLast methods to reposition the current record. For dynaset- and snapshot-type Recordset objects, you can also use the Find methods, such as FindFirst, to locate a specific record based on criteria. If the record isn't found, the NoMatch property is set to True. For table-type Recordset objects, you can scan records using the Seek function. To cycle through all records, you can use the BOF and EOF properties to check for the beginning or end of the Recordset object. However, it may run faster to with an SQL query that performs operations that apply to an entire set of records. Properties AbsolutePosition Property; BOF, EOF Properties; Bookmark Property; Bookmarkable Property; CacheSize, CacheStart Properties; DateCreated, LastUpdated Properties; EditMode Property; Filter Property; Index Property; LastModified Property; LockEdits Property; Name Property; NoMatch Property; PercentPosition Property; RecordCount Property; Restartable Property; Sort Property; Transactions Property; Type Property; Updatable Property; ValidationRule Property; ValidationText Property. Methods AddNew Method; CancelUpdate Method; Clone Method; Close Method; CopyQueryDef Method; Delete Method; Edit Method; FillCache Method; FindFirst, FindLast, FindNext, FindPrevious Methods; GetRows Method; Move Method; MoveFirst, MoveLast, MoveNext, MovePrevious Methods; OpenRecordset Method; Requery Method; Seek Method; Update Method. See Also Dynaset-Type Recordset Object; Index Object; OpenRecordset Method; Snapshot-Type Recordset Object; Table-Type Recordset Object; Appendix, "Data Access Object Hierarchy." Example This example creates a new Recordset object and opens it (thereby appending it to the Recordsets collection) in the default database. Then the example enumerates all the Recordset objects in the current database and all the fields in each Recordset object and closes the new Recordset.
Function EnumerateRecordset () As Integer Dim dbsExample As Database, rstOrders As Recordset Dim rstTemp As Recordset Dim I As Integer, J As Integer Set dbsExample = _ DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb") Set rstOrders = dbsExample.OpenRecordset("Orders", dbOpenSnapshot) Debug.Print ' Enumerate all Recordset objects. For J = 0 To dbsExample.Recordsets.Count - 1 Set rstTemp = dbsExample.Recordsets(J) Debug.Print Debug.Print "Enumeration of Recordset objects("; J; "): "; _ rstTemp.Name Debug.Print ' Enumerate fields. Debug.Print "Fields: Name, Type, Value" For I = 0 To rstTemp.Fields.Count - 1 Debug.Print " "; rstTemp.Fields(I).Name; Debug.Print ", "; rstTemp.Fields(I).Type; If rstTemp.Fields(I).Type = dbText Then Debug.Print ", "; rstTemp.Fields(I).Value End if Next I Next J dbsExample.Close EnumerateRecordset = True End FunctionExample (Microsoft Access) The following example opens a table-type Recordset object, a dynaset-type Recordset object, and a snapshot-type Recordset object. Then it displays the value of the Updatable property for the Recordset objects.
Sub NewRecordsets() Dim dbs As database, rst As Recordset Dim rstEmployees As Recordset, rstOrders As Recordset Dim rstProducts As Recordset, strSQL As String ' Return Database object pointing to current database. Set dbs = CurrentDb ' Create table-type Recordset object. Set rstEmployees = dbs.OpenRecordset("Employees", dbOpenTable) ' Construct SQL string. strSQL = "SELECT * FROM Orders WHERE OrderDate >= #1-1-95#;" ' Create dynaset-type Recordset object. Set rstOrders = dbs.OpenRecordset(strSQL, dbOpenDynaset) ' Create snapshot-type Recordset object. Set rstProducts = dbs.OpenRecordset("Products", dbOpenSnapshot) ' Print value of Updatable property for each Recordset object. For Each rst In dbs.Recordsets Debug.Print rst.Name; " "; rst.Updatable Next rst End Sub