Method
Adds keys and SumIndexFields to a table.
Category
Database
Syntax
Sub AddKey(hCreateTable As Long, ByVal Key As Variant, ByVal SumKey
As Variant)
hCreateTable
A create table handle (see CreateTableBegin).
Key
The zero-terminated array of the field numbers (as integers) that
you want to constitute the key.
SumKey
The zero-terminated array of the field numbers (as integers) for
which you want SumIndexFields to be maintained.
Example
'Creates table Number from Parameter1 and Name from Parameter2
CF1.CreateTableBegin hTable, CLng(.Text1(cf.TableNoCreate)), .Text1(cf.TableNameCreate), 1
logWr "CreateTableBegin: " + Str(hTable)
CF1.AddTableField hTable, 1, "Field1", 7, 2, "", 0
CF1.AddTableField hTable, 2, "Field2", 7, 2, "", 0
'Adding Key
IntArray(0) = 1
IntArray(1) = 2
IntArray(2) = 0
KeyArray = IntArray
CF1.AddKey hTable, KeyArray, KeyArray
logWr "Addkey result: OK"
tmpVar = CF1.CreateTable(hTable)
If VarType(tmpVar) = vbBoolean And tmpVar = True Then
logWr "CreateTable result: OK"
Else
logWr "CreateTable result: Failed"
End If
CF1.CreateTableEnd hTable
logWr "CreateTableEnd: " + Str(hTable)
Comments
The first time you call AddKey you create the primary key and the
SumIndexFields that are associated with the primary key.
You can add more keys and SumIndexFields by making more AddKey calls.
The fields and the table are not created in the database until you call CreateTable.