TrkRecords.Add (method)

Add
Syntax: TrkRecord = object.Add ( )
Description:
Adds a new record to the TrkRecords Collection. TrkRecords object maintains a collection of records in the memory. This method inserts a new TrkRecord object into the collection only. The method does not automatically insert a record in the corresponding table in the database. No new rows are inserted into the TADB Database until TrkRecord.Save method is called.

If successful, the method returns a valid TrkRecord that can later be used to insert rows into the database after updating values, by calling the Save method. If the method fails to add a new TrkRecord object, the return value is Nothing.

Example 1:

Dim oTrkTable As Object
Dim oTrkRecord As Object
Dim oTrkField As Object
Dim oTADBRoot As Object
Dim idx As Long

Set oTADBRoot = CreateObject("TADB.TADBRoot")

If oTADBRoot Is Nothing Then
   MsgBox "Root Object is not created"
End If

oTADBRoot.Load "TRK7", ""

'Get Table from Collection of TrkTables
Set oTrkTable = oTADBRoot.TrkTables.Item("GroupAttribs^BODY COMPONENT^Body IDs")
If oTrkTable Is Nothing Then
    'Item Not found
Else
    'TrkTable Found ...
    oTrkTable.ReadDB "Item3"
    Set oTrkRecord = oTrkTable.TrkRecords.Add()
    If Not oTrkRecord is Nothing then
       MsgBox "Records Index:" & oTrkRecord.ID
       oTrkRecord.TrkFields.Item("id").Value = "Item4"
       oTrkRecord.TrkFields.Item("Check Digit").Value = "A1"
       oTrkRecord.TrkFields.Item("CID").Value = "B2"
       oTrkRecord.TrkFields.Item("Smart Eye ID").Value = "1234"
       oTrkRecord.TrkFields.Item("Transponder ID").Value = "5678"
       oTrkRecord.TrkFields.Item("Transponder Programmed").Value = "12/01/2002"
       oTrkRecord.Save
    Else
       'Record object is empty...
    End If
End If
...

Example 2:

Dim oTrkTable As Object
Dim oTrkRecord As Object
Dim oTrkField As Object
Dim oTADBRoot As Object
Dim idx As Long

Set oTADBRoot = CreateObject("TADB.TADBRoot")

If oTADBRoot Is Nothing Then
   MsgBox "Root Object is not created"
End If

oTADBRoot.Load "TRK7", ""

'Get Table from Collection of TrkTables
Set oTrkTable = oTADBRoot.TrkTables.Item("GroupAttribs^VEHICLE ORDER^Blends_lookup")
If oTrkTable Is Nothing Then
    'Item Not found
Else
    'TrkTable Found ...
    oTrkTable.ReadDB
    Set oTrkRecord = oTrkTable.TrkRecords.Add()
    If Not oTrkRecord is Nothing
       MsgBox "Records Index:" & oTrkRecord.ID
       oTrkRecord.TrkFields.Item("Name").Value = "Blend 1"
       oTrkRecord.Save"
    Else
       'Record object is empty...
    End If
End If
...

Important Note:This method allocates memory for the returned TrkRecord. After the TrkRecord has been saved to the database you can free this memory by calling the TrkRecords.RemoveFromCollection method.