Access VBA Macro Programming

(Joao Candeias) #1

MoveFirst


TheMoveFirstmethod selects the first record in the recordset.


RecSet.MoveFirst


MoveLast


TheMoveLastmethod selects the last record in the recordset.


RecSet.MoveLast


MoveNext


TheMoveNextmethod selects the next record in the recordset.


RecSet.MoveNext


This method is essential when iterating through a recordset. It is very easy to forget to
include it in your code.


MovePrevious


TheMovePreviousmethod selects the previous record in the recordset.


RecSet.MovePrevious


NoMatch


The NoMatch property is used after doing a Find such as FindFirst. It returns True if a match
was found from the criteria, and False if not. It can then be used with anIfstatement to take
appropriate action.


RecSet.FindFirst ("MyField='Data'")
MsgBox RecSet.NoMatch


RecordCount


TheRecordCountproperty returns the number of records within the recordset. It is useful to
test a query or table to find out if there is any data in it by using the following:


MsgBox RecSet.RecordCount


Requery


TheRequerymethod re-queries the recordset. In a multiuser environment, other users may
have made changes to the underlying table while your code is running, making the data in the
recordset stale.


Update


TheUpdatemethod is used to update the underlying table after an AddNew or Edit has taken
place within the recordset. If no update is done, then changes will be lost.


Chapter 15: The Main Objects 211

Free download pdf