Purpose
This property can be used to read or update a record's key. It provides
an intuitive way to manipulate record keys as if they were elements
in an array.
Syntax (Read/Write Property)
(Read)
Key =
object.RecordKey(Index)
(Write) object.RecordKey(Index)
= Key
| Index
(Long) |
|
This
is the record number you want to read from. |
| Key
(String) |
|
This
is the key returned from the specified record. |
| Index
(Long) |
|
This
is the record number you want to write to. |
| Key
(String) |
|
This
is the key to assign to the specified record. |
Notes
(Read)
This property allows you to retrieve a key from a specified record.
If
the specified record (Index)
does not exist, the property returns a zero-length string and ErrorNumber
reports rtCDP_ErrRecordNotFound.
If
any errors occur, the function returns a zero-length string ("").
Notes
(Write)
This property allows you to update records in the database.
If
the specified record number (Index)
is higher than the highest record in the database, then all necessary
records are added until the specified record exists. The new records
have zero-length keys and data, except for the specified record, which
is assigned the specified key (Key).
All
records added by this property contain zero-length data.
If
any errors occur, no records are changed.
Error
Values (Read)
After reading this property, the property ErrorNumber
will report one of the following values:
rtCDP_ErrNoError
rtCDP_ErrRecordNotFound
Error
Values (Write)
After writing this property, the property ErrorNumber
will report one of the following values:
rtCDP_ErrNoError
rtCDP_ErrDataTooLong
rtCDP_ErrRecordNotFound
Example
Objective: Use the Compact Data Pak like an automated array (an array
that automatically allocates elements as needed).
'Create
a database
Dim CDP As
rtCDP.rtCompactDataPak
Set CDP = New rtCDP.rtCompactDataPak
'Add
some records to the database
CDP.RecordKey(2) = "Allisa"
This
is the current state of the database:
| Rec |
Key |
Data |
| 0 |
. |
. |
| 1 |
. |
. |
| 2 |
Allisa |
. |
'Now,
update an existing record's data
CDP.RecordKey(0)
= "Tatia"
This
is the current state of the database:
| Rec |
Key |
Data |
| 0 |
Tatia |
. |
| 1 |
. |
. |
| 2 |
Allisa |
. |
'Now,
add some more records
CDP.RecordKey(4)
= "Mellisa"
This
is the current state of the database:
| Rec |
Key |
Data |
| 0 |
Tatia |
. |
| 1 |
. |
. |
| 2 |
Allisa |
. |
| 3 |
. |
. |
| 4 |
Mellisa |
. |
'Now,
edit an existing record
CDP.RecordKey(0)
= "Kathy"
This
is the current state of the database:
| Rec |
Key |
Data |
| 0 |
Kathy |
. |
| 1 |
. |
. |
| 2 |
Allisa |
. |
| 3 |
. |
. |
| 4 |
Mellisa |
. |
'Now,
read back a value from a record
Dim
FirstName As String
FirstName = CDP.RecordKey(0)
'FirstName = Kathy
FirstName
= CDP.RecordKey(1)
'FirstName = ""
FirstName
= CDP.RecordKey(5)
'FirstName = ""
Version
History
(Read) 1.0 2/2/2001 Tested
(Write) 1.0 2/2/2001 Tested
See
Also
Record, RecordB