To code the Update button, we disable the Employee Number text box to disallow
changes to this field while updating, since this is a primary key. We also
disable the other buttons to disallow other functions such as navigation while
updating.
We set the DoUpdate boolean to TRUE, so the commit procedure knows we are
updating and not adding a record.
The Update event procedure does the following:
Disables Update button.
Enables the Commit button.
Disables other buttons to disallow functions such as navigation during update.
Disables the Employee Number text box.
Sets the DoUpdate flag to true.
Lets user enter changes.
The Update event procedure looks like:
Private Sub cmdUpdate_Click()
'Disable the Update button and enable the commit button
cmdUpdate.Enabled = False
Commit.Enabled = True
'Disable all other buttons
DisableNavButtons
txtEmpno.Enabled = False
DoUpdate = True
End Sub
The Update and Add event procedures call the DisableNavButtons() subroutine to
disable navigation and other functions during an add or update.
Private Sub DisableNavButtons()
'disable all buttons while adding and updating
cmdFirst.Enabled = False
cmdPrevious.Enabled = False
cmdNext.Enabled = False
cmdLast.Enabled = False
cmdFind.Enabled = False
cmdUpdate.Enabled = False
AddNew.Enabled = False
End Sub