Page 520 - Microsoft Office Excel 2003 Programming Inside Out
P. 520

Microsoft Office Excel 2003 Programming Inside Out

                             The Delete method deletes the current row and sets the EditMode property to adEditDelete.
                             Again, you need to use the Update method to make the changes final.
                             One nice feature of the Recordset object is the CancelUpdate method. If you have made any
                             changes to the current row and call CancelUpdate, all the changes will be discarded and the
                             original values would be restored. If you had added a new row using the AddNew method, the
                             new row will be discarded and the current record pointer will be reset to point to the row it
                             was pointing to prior to calling AddNew.


                    Using the Fields Collection
                             The Fields collection contains information about the columns in the current row of the
                             Recordset object. (See Table 23-9.)
                             Table 23-9.  Key Properties of the Fields Collection

                             Property/Method     Description
                             Count               Property: returns the number of items in the collection.
                             Item(index)         Property: returns the Field object at the location specified by index.

                             For the most part, you’ll use the Fields collection simply to access the various Field objects
                             associated with the current row. The other properties and methods in the Fields collection
                             exist to add and remove Field objects from the collection and aren’t critical to the average
                             database programmer.


                    Using the Field Object
                             The Field object contains information about a single column associated with the current row
                             of the Recordset object. Some of the most useful properties are listed in Table 23-10.
                             Table 23-10.  Key Properties of the Field Object
                             Property            Description

                             Name                Contains the name of the database column.
                             OriginalValue       Contains the original value of the field from the database.
                             Type	               Contains the OLE DB data type of the column. Some common
                                                 values are adSmallInt, adInteger, asSingle, adDouble, adCurrency,
             Chapter 23
                                                 adDate, adBSTR, adBoolean, adDecimal, adBigInt, adBinary,
                                                 adChar, adWChar, adNumeric, adDBDate, adDBTime,
                                                 adVarNumeric, adVarChar, adLongVarChar, adVarWChar,
                                                 adLongVarWChar, adVarBinary, and asLongVarBinary.
                             UnderlyingValue     Contain the current value of the column as found in the database.
                             Value               Contain the current value of the field.




                494
             Part 6:  Excel and the Outside World: Collaborating Made Easy
   515   516   517   518   519   520   521   522   523   524   525