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

DatabaseObjects

ObjectByOrdinal(ByVal objCollection As IDatabaseObjects, ByVal lngIndex As Long) As IDatabaseObject

ObjectByOrdinal returns an object from the collection at a specific ordinal/index position. The ordinal position is related to the collection's IDatabaseObjects_OrderBy value. Typically, this function is used to enumerate through a collection of objects. ObjectByOrdinal will load the collection's entire recordset on the first call and on subsequent calls any objects are loaded using the pre-loaded recordset. Avoid making calls to ObjectByOrdinal for different tables, as the entire recordset will be reloaded on each call. To load the first object in a table without loading the entire table, use the ObjectByOrdinalFirst function.

'Access the 1st product in the collection Set objProduct = DBO.ObjectByOrdinal(objProducts, 1) 'Access the 10th product in the collection 'This will not make another call to the database as all of the products 'will already be loaded into a temporary recordset from the call above. Set objProduct = DBO.ObjectByOrdinal(objProducts, 10)