Creating a New Key Member
This topic describes how to define data members to form an explicit single-member or multi-member key for a class. The class must already exist, and a key must be defined for the class. The class must already contain the data members that will form the key.
You create a key member by creating a new row in the keymem table, populating the columns, and saving the changes. For information about the keymem table, see Keymem Table: Key Member Definition Metadata.
The following table lists the columns and values of the keymem table for the first member, ordergroup_id, of the OrderFormHeader class key. Unspecified optional columns are not shown. In the R/O column, R = required, O = optional.
Column name |
Column value |
Type |
R/O |
Purpose |
---|---|---|---|---|
KeyDefName |
"myOrderFormHeaderKey " |
String |
R |
Name of the class key. |
MemberName |
"ordergroup_id" |
String |
R |
Identifies the data member that is part of the class key. |
OrdinalPosInKey |
0 |
Integer |
R |
The position of the data member in the key composition, starting with 0 (zero). The key is guaranteed unique only when the data members are processed in a specific order. |
Description |
"First member of myOrderFormHeaderKey." |
String |
O |
Describes the key member. |
The following table describes the columns and values of the keymem table for the second member, "OrderForm_Id", of the OrderFormHeader class key. Unspecified optional columns are not shown. In the R/O column, R = required, O = optional.
Column name |
Column value |
Type |
R/O |
Purpose |
---|---|---|---|---|
KeyDefName |
"myOrderFormHeaderKey " |
String |
R |
Name of the class key. |
MemberName |
"OrderForm_Id" |
String |
R |
Identifies the data member that is part of the class key. |
OrdinalPosInKey |
1 |
Integer |
R |
The position of the data member in the key composition, starting with 0 (zero). |
Description |
"Second member of myOrderFormHeaderKey." |
String |
O |
Describes the key member. |
Example - Step 5
Create the members of the OrderFormHeader class key.
Note
The code in this example is for demonstration only.
'Create an instance in the Key Member table for the first member.
recNew.Open "KeyMember/myOrderFormHeaderKey/ordergroup_id", _
cnnConnection, adModeWrite, adCreateOverwrite
'Set the attributes for the first key member.
recnew("MemDefName") = "ordergroup_id"
recNew("OrdinalPosInKey") = 0
recNew("Description") = "First member of myOrderFormHeaderKey."
recNew("KeyDefName") = myOrderFormHeaderKey
'Save the new row.
recNew("__Commit") = 1
recNew.Update
recNew.Close
'Create an instance in the Key Member table for the second member.
recNew.Open "KeyMember/myOrderFormHeaderKey/OrderForm_Id", _
cnnConnection, adModeWrite, adCreateOverwrite
'Set the attributes for the second key member.
recnew("MemDefName") = "OrderForm_Id"
recNew("OrdinalPosInKey") = 1
recNew("Description") = "Second member of myOrderFormHeaderKey."
recNew("KeyDefName") = myOrderFormHeaderKey
'Save the new row.
recNew("__Commit") = 1
recNew.Fields.Update
recNew.Close
The next step is to create a relation between the "new" OrderFormHeader class and the existing OrderGroup class. Continue to Creating a New Class Relation.