5.3.5 Saving Changes / Inserting Records
The command button, Save, is used to Insert or Update a record. Before updating the data entered by the user, it has to be set in the session buffer. In this case it is done in the Change Event of the form fields.
Note : A value of '''' is invalid as it is not a null terminated string, chr(0) must be used instead.
Private Sub txtCode_LostFocus ()
If txtCode <> "" Then
iRet = LceSetFieldValue(iSession, "SKILCODE", txtCode)
'-----------------------------------------------------
Else
' note we require a null terminated string
iRet = LceSetFieldValue(iSession, "SKILCODE", Chr(0))
End If
End Sub
Private Sub cmdSave_Click()
If bAdding = True Then
' user is inserting a new record
iRet = LceInsert(iSession, "SKILCODE,SKILDESC", _
"SKLTAB", LceFalse)
'-----------------------------------------------------
Else
' user is saving changes record
iRet = LceUpdate(iSession, "SKILCODE,SKILDESC", _
"SKLTAB", "SKILCODE", LceFalse)
'------------------------------------------------------
End If
If iRet = LceTrue Then
' if successful force a refresh so list shows changes
Call RefreshSkillsList
End If
End Sub