Creates a record buffer.



Function AllocRec(ByVal hTable As Long) As Long

The handle to the table.



 ' Case "FindRec", AllocRec and NextRec

 ' Open Table 15 (G/Ledger)

  CF1.OpenTable hTable, 15

  hRecord = CF1.AllocRec(hTable)


  ' get last record

  tmpVar = CF1.FindRec(hTable, hRecord, "+")

  If VarType(tmpVar) = vbBoolean Then

  logWr "FindRec OK"


  logWr "FindRec failed. It didn't return a boolean"

  End If

  tmpLastRecord = CF1.GetFieldData(hTable, hRecord, 1)


  ' loop through records

  CF1.FindRec hTable, hRecord, "-"

  tmpLong2 = 1 'used to count no of records

  tmpLong = CF1.GetFieldData(hTable, hRecord, 1)

  Do While tmpLong <> tmpLastRecord

  tmpVar = CF1.NextRec(hTable, hRecord, 1)

  If VarType(tmpVar) <> vbInteger Then

  logWr "NextRec failed. It didn't return an Integer"

  End If

  tmpLong = CF1.GetFieldData(hTable, hRecord, 1)

  tmpLong2 = tmpLong2 + 1


  logWr "Stepped through " & Trim$(Str$(tmpLong2)) & " records. Data from the last one: " + Str$(tmpLastRecord)


  CF1.FreeRec hRecord


AllocRec creates a record buffer for the specified table handle. If it is successful, a handle for the record is returned. A record buffer is a memory area that has the same size as a record (including virtual fields FlowFields and FlowFilters) in the specified table. Changes to the buffer do not affect the table. You change or add table records by using InsertRec, ModifyRec or DeleteRec. If enough memory is not available, the function will raise an exception. Always use FreeRec to remove the record buffer returned by AllocRec from memory.

© 2009 Microsoft Corporation. All rights reserved.