Microsoft Office Tutorials and References
In Depth Information
Validating data entered in controls
Validating data entered in controls
Controls on a form have a Before Update event that enables you
to use macro commands to add actions when a user enters data
before the entry is accepted. You can then decide whether to
accept or reject the data entered in the control.
The Form’s Before Update event executes before a record
is saved. You can use this event to check the data,
comparing values in multiple controls, before accepting or rejecting
changes. If you need to cross-validate controls, it is often simpler
to write the macro checking actions on the forms event, rather
than repeating similar operations on several different controls.
Validate data entered in a control
1 In Design view, locate a control on which you want to add
validation, and click the Event tab in the Property Sheet pane to display
the event properties. In our example, we have created a new form
and added an unbound text box control to the form.
2 Click the build button for the Before Update event, and select
Macro Builder.
3 Select the If command in the Add New Action field. This is a
conditional logic block where we can test a value and take an action.
4 Type the expression nZ(txtLowerCount) < 10 ; IntelliSense will
display a list of controls after you type nZ . (Our control is called
5 In the drop-down box below the If command, select the
MessageBox action in the Add New Action field. Type a warning
message and a title for the MessageBox action.
(continued on the next page)
Search JabSto ::

Custom Search