AddTableField

Method
Adds a field to a table.

Category
Database

 

Syntax
Sub AddTableField(hCreateTable As Long, FieldNo As Long, FieldName As String, FieldType As Short, FieldLen As Short, OptionStr As String, FieldClass As Short)

hCreateTable
A create table handle (see CreateTableBegin).

FieldNo
The number of the field to add.

FieldName
The name of the field to add.

FieldType
The type of the field to add. The following table shows the relationship between the value of FieldType and the corresponding type in C/SIDE:

Value:

Field Type:

0

Text

1

Date

2

Time

3

Boolean

4

Integer

5

Code

6

Option

7

Decimal

8

BLOB

FieldLen
The length of the field to add. This is only relevant for the Text and Code field types. This corresponds to the length you declare in C/SIDE (as opposed to the actual length of data in a field).

OptionStr
A comma-separated string of option values. This is only relevant for a field of type Option.

FieldClass
The class of the field to add. The following table shows how a FieldClass value corresponds to a field class in C/SIDE:

0

Normal

1

FlowField

2

FlowFilter

 

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)

'Adds two fields 1and 2, named Field1 and Field2, of type Decimal, length 2, empty option string, FieldClass=Normal

  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
AddTableField adds a field to a table. You must have acquired a create table handle by calling CreateTableBegin. The table will not be created in the database before you call CreateTable on the create table handle.

You can create keys and SumIndexFields by using AddKey.



© 2009 Microsoft Corporation. All rights reserved.