5 3 4 Setting a New Record s Fields to Default Values

LANSA Open Guide

5.3.4 Setting a New Record's Fields to Default Values

A new record is added to a table using LceInsert. In this case, the Add command button is used only to set the default values of the fields retrieved from the dictionary (clears record). On Save, either LceInsert or LceUpdate is called, depending on whether the current record is being added or edited.

 

Private Sub cmdAdd_Click()

    

    

    'Code

    sBuff = String(FIELD_DATA_SIZE, Chr(0))

    iRet = LceGetDefaultValueX(iSession, "SKILCODE", sBuff, lFlags)

    '-----------------------------------------------------

    If lFlags = 1 Then

        txtCode = "Null value"

    Else

        txtCode = sTrim(sBuff)

    End If

    

    'Desc

    sBuff = String(FIELD_DATA_SIZE, Chr(0))

    iRet = LceGetDefaultValueX(iSession, "SKILDESC", sBuff, lFlags)

    '-----------------------------------------------------

    If lFlags = 1 Then

        txtDesc = "Null value"

    Else

        txtDesc = sTrim(sBuff)

    End If

    

    'set flag to indicate that a new record is being added.

    'this flag is used in the cmdSave_Click() subroutine

    bAdding = True

 

End Sub