ObjectSave(ByVal objCollection As IDatabaseObjects, ByVal objItem As IDatabaseObject)
ObjectSave extracts the fields to save to the database from the SaveFields function. ObjectSave then writes the object's record to the database. If the object has not yet been saved to the database then a new record is inserted. If the object has already been saved then the record is amended. The objCollection argument is the collection associated with the objItem. If the collection has implemented DatabaseObjects_KeyFieldName then objItem's key is checked to ensure it is not null and is unique within the collection. If the objCollection has implemented the IDatabaseObjects_Subset function then objItem should exist within objCollection. If not, a duplicate key error may occur if the obItem's key is being used in another subset in the same table.
If a record is being amended (IDatabaseObject_IsSaved returns true) then the function will AND the collection's IDatabaseObjects_Subset conditions and the objItem's IDatabaseObject_DistinctValue value to create the WHERE clause in the UPDATE statement. Therefore, the combination of the IDatabaseObjects_Subset and IDatabaseObject_DistinctValue conditions MUST identify only one record in the table. Otherwise multiple records will be updated with the same data. If data is only inserted and not amended (usually a rare occurance) then this requirement is unnecessary.
'This is typically how the ObjectSave function is used. 'i.e. in the Product class the following would be used: Public Sub Save() 'Save this product to the products table DBO.ObjectSave gobjGlobalProductsInstance, Me End Sub