AddNew Method

Microsoft Office Web Components Object Model

AddNew Method

       

Creates a new schema row source and a recordset definition. Returns a RecordsetDef object.

expression.AddNew(Source, RowsourceType, Name)

expression   An expression that returns a RecordsetDefs  object.

Source   Required String. Specifies command text for a new schema row source of type dscCommandText or dscCommandFile, or for the name of a table, view, or stored procedure to be added as a schema row source. For more information, see the Help topic for the CommandText property.

RowsourceType   Optional Variant. Specifies the type of the new schema row source. Can be one of the dscRowsourceTypeEnum constants. The default constant is dscCommandText.

Name   Optional Variant. Specifies the name of the recordset definition, page row source, and schema row source created by using the AddNew method. If you do not specify this argument and the value of the RowsourceType argument is dscTable, dscView, or dscProcedure, the new name is the same as the name specified in the Source argument (with numerals automatically appended to it to make it unique, if necessary). If you do not specify this argument and the value of the RowsourceType argument is dscCommandText or dscCommandFile, the new name is "CommandN", where N is one or more appended numerals.

Remarks

Page fields are normally created with names that are unique throughout the page data definition. However, when a page field is added to a recordset definition whose primary page row source is of type dscProcedure, dscCommandText, or dscCommandFile, the page field name must be the same as the schema field name. This can result in multiple page field objects with the same name in the AllPageFields collection. To differentiate between objects with the same name, you can use the expression AllPageFields("RecordsetdefName.PagefieldName") where RecordsetdefName is the name of the recordset definition, and PagefieldName is the name of the page field. Note that page field names themselves cannot contain periods.