Database Objects
Hi-Integrity Systems
HomeVB6 Documentation › DBO.ObjectDelete


ObjectDelete(ByVal objCollection As IDatabaseObjects, ByRef objItem As IDatabaseObject)

ObjectDelete deletes an object's database record. If the collection's IDatabaseObjects_Subset has been implemented then the object must exist within the subset, otherwise the object will not be deleted. If the object has not been saved to the database the function will exit without executing an SQL DELETE command. After deleting the database record the object is set to Nothing. The calling function must specify ByRef not ByVal for the object, for this to have any affect. Setting the object to Nothing minimises the possibility of the deleted object being used in code after ObjectDelete has been called.

Dim objProduct As Product 'Select product with code "PC12345" Set objProduct = DBO.ObjectByKey(objProducts, "PC12345") 'Delete product "PC12345" DBO.ObjectDelete objGlobalProductsInstance, objProduct 'objProduct will now be Nothing