Microsoft Office Tutorials and References
In Depth Information
Validating Data
Place the following code in the On-Click event of the list box:
' Check for the special character * to show all rows¶
If Me.lstChar = * Then¶
' reset filter to show all¶
' by deactivating the FilterOn property¶
Me.sfrmName.Form.FilterOn = False¶
' set filter to show names that match the selected first character¶
Me.sfrmName.Form.Filter = [Lastname] like ' & Me.lstChar & *'¶
' activate the filteron property¶
Me.sfrmName.Form.FilterOn = True¶
End If¶
' Make sure changes will be displayed¶
The following code goes in each of the After Insert, After Delete Confirm, and
After Update events of the subform:
' Refresh the listbox on the parent form¶
Instead of moving a field to the parent form, simply requery the list box to
ensure it reflects all current values.
Validating Data
Use this procedure to validate data entered into a form before saving a record.
Example file:
A011.mdb with
frmNameSelect and
Scenario: When users are entering or editing data, mistakes
can occur. Before storing the data, you can test to ensure
that mandatory fields have been completed. You can also
check that related fields (like start and end dates) are
logically correct (start date needs to be equal or less than the
end date).
Select a row and press the Update button to see which error
messages occur when editing the update form.
Search JabSto ::

Custom Search