Validate or restrict data in a form

Microsoft Office Access 2003

  1. Open a form in Design view.
  2. Select a text box or a combo box, and then click Properties Button image on the toolbar to open the control's property sheet.
  3. In the InputMask property box, do one of the following:

    Type the input mask definition.

    In a Microsoft Access database (.mdb), click the Build button Button image in the InputMask property box to start the Input Mask Wizard, and then follow the instructions in the wizard dialog boxes.

ShowCreate a validation rule for a control

  1. Open a form in Design view.
  2. Select a control, and then click Properties Button image on the toolbar to open the control's property sheet.
  3. In the ValidationRule property box, do one of the following:

    Type the validation rule.

    In a Microsoft Access database (.mdb), click the Build button Button image to use the Expression Builder to create the validation rule.

  4. In the ValidationText property box, type the error message that you want displayed if the text entered violates the validation rule.

Note  In an Access database, if you set the ValidationRule property for the field in table Design view and also set the ValidationRule property for a control bound to that field, Access enforces both rules— the control validation rule doesn't override the field validation rule.

ShowLock or disable a control

  1. Open a form, report, or data access page in Design view.
  2. Make sure that the control is selected, and then click Properties Button image on the Form Design, Report Design, or Page Design toolbar to open its property sheet.
  3. In a form or report, do one of the following:
    • If you want to disable the control completely so that it's dimmed and can't receive the focus, set the Enabled property to No.
    • If you want to make data in the control readable, but not allow users to change the data, set the Locked property to Yes. If you set the Enabled property to No and the Locked property to Yes, the control won't appear dimmed, but it won't be able to receive the focus.

    In a data access page, to disable the control completely so that it's dimmed and can't receive the focus, set the Disabled property to True.

Show Tip

In a form or report, you can use the Enabled property together with the AfterUpdate property to disable a control until a user enters text or makes a selection in another control. For example, you might want to disable a command button until data has been entered in a text box. You can use the AfterUpdate property of the text box to call an event procedure or a macro to enable the command button.

Notes

  • If you need more room to type in a property box, press SHIFT+F2 to open the Zoom box.
  • Microsoft Access validates a field when you change data and try to leave the field, save the record, switch views, or close the form.