AddNew Method
Creates and initializes a new record for an editable Recordset
object.
RecordsetObject.AddNew()
Client support
Newlook Smartclient
Newlook Server
Parameters
None.
Use
The AddNew method sets the EditMode
property of the Recordset to EditAdd. Any changes to the new record
are cached locally. The Update method
posts the new record to the database and resets the EditMode property
to EditNone. The CancelUpdate method
deletes the new record and resets the EditMode property to EditNone.
If you call the AddNew method while editing
the current record or while adding a new record, the Update
method is called to save any changes before the new record is created.
Examples
The following newrecord() and saverecord() functions could be attached to command buttons on your form titled "New" and "Save" respectively. These functions allow you to create a new record in the open recordset and update that record with values of fields on your form.
JSCRIPT
// Add a new record to the recordset
function newrecord()
{
SampleRecordset.AddNew ();
clearrecord ();
}
// Save any changes to the current record
function saverecord()
{
setrecord ();
SampleRecordset.Update ();
}
// Clear the fields on the form
function clearrecord()
{
App.ActiveForm.CustomerName.Text = "";
App.ActiveForm.CustomerNumber.Text = "";
App.ActiveForm.Balance.Caption = "";
}
// Update the current record with the details from the fields on the form
function setrecord()
{
SampleRecordset.Fields(0).Value = App.ActiveForm.CustomerName.Text;
SampleRecordset.Fields(1).Value = App.ActiveForm.CustomerNumber.Text;
SampleRecordset.Fields(2).Value = App.ActiveForm.Balance.Caption;
}
|
See Also
DBConnect Method | Open Method | Disconnect Method | Close Method | Find Method | Move Method | AddNew Method | BeginTrans Method | CancelUpdate Method | CommitTrans Method | Delete Method | RollbackTrans Method | Seek Method | Update Method | ConnectionString
property | DB Connection object
Applies To
Recordset object
©
2004-2021 looksoftware.
All rights reserved.