Microsoft Office Tutorials and References
In Depth Information
Validating Data
Figure 93 – Data Entry Form
The mandatory fields have been marked with an asterisk (*). Empty these
fields to see the effect.
Many developers try to validate each field, but being forced to enter a value in
a field before proceeding to another field can be frustrating for users, so all
testing is done when the Save button is pressed, and all errors report to the
user in a message box. To show which fields were in error, change the
background color so that, even after the message box is closed, the user is
aware of the error that must be corrected. Finally, we place the cursor in the
first field that is wrong.
The code that provides this functionality is a follows:
Private Sub btnSave_Click()¶
Dim strMessage As String¶
' reset all backcolors in case errors have been reported previously¶
Me.Phone.BackColor = vbWhite¶
Me.DOB.BackColor = vbWhite¶
Me.DateStartMembership.BackColor = vbWhite¶
Me.DateStartMembership.BackColor = vbWhite¶
Search JabSto ::

Custom Search