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

DatabaseObjects

ObjectItem(ByVal objCollection As IDatabaseObjects, ByVal vIndex As Variant) As IDatabaseObject

ObjectItem either calls the ObjectByOrdinal or ObjectByKey functions depending on the vIndex data type. If vIndex is an integer or long then the ObjectByOrdinal function is called. If vIndex is any other data type then the ObjectByKey function is called. The example below demonstrates the two uses of this function.

'Example 1 - Utilises the ObjectByOrdinal function 'Return the 10th product in the collection Set Product = DBO.ObjectItem(objProducts, 10) 'Example 2 - Utilises the ObjectByKey function 'Return product with product code "ABC" Set Product = DBO.ObjectItem(objProducts, "ABC") 'Typically, the function is used in the manner below. 'For example, in the Products class the following would be used 'to access either a product by an ordinal number or by the 'product's key field; the product code Public Property Get Item(ByVal vIndex As Variant) As Product Set Item = DBO.ObjectItem(Me, vIndex) End Property