Recordset.AddNew

Add a new record to a recordset.

Syntax
      expression.AddNew

The Move methods move from record to record without applying a condition.

To find records that meet a specific condition — use a Find method to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If you move to another record without updating (with the Update method), your changes will be lost without warning.

When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.

If the first or last record is already current when you use MoveFirst or MoveLast, the current record doesn't change.

If recordset refers to a table-type Recordset (Access workspaces only), movement follows the current index. Set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.

You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward–only–type Recordset object.

To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.

Example

Dim db As Database
Dim rst As Recordset

Set dbs = OpenDatabase("Northwind.mdb")
Set rst = dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)
      
With rst
   .AddNew
   !FirstName = "Fred"
   !LastName = "Bloggs"
   .Update
End With

“Twenty years from now, you will be more disappointed by the things you didn't do than by the ones you did do. So throw off the bowlines, sail away from the safe harbour. Catch the trade winds in your sails. Explore. Dream. Discover” ~ Mark Twain

Related:

MoveFirst/Last/Next/Previous Record
RecordSet.Clone - Create a duplicate Recordset
Recordset.CopyQueryDef - Create a duplicate QueryDef
RecordSet.Close - Close a recordset
OpenRecordset - Create a new Recordset
CancelUpdate - Cancel recordset changes
Update - Save a recordset.


© Copyright SS64.com 1999-2013
Some rights reserved