Required field in a textbox RRS feed

  • Question

  • How do you ensure a required textbox on a form is not left empty?
    Thursday, April 12, 2018 8:39 PM

All replies

  • If the Textbox is bound to a field in a table, then one way is to set the Required property in the table to Yes.

    Hope it helps...

    Thursday, April 12, 2018 8:43 PM
  • How do you ensure a required textbox on a form is not left empty?

    Hi Gordon,

    Another way is to test for a Null value in the BeforeUpdate event. If Null, then set Cancel = TRUE.


    Added: this works for both bound and unbound controls.

    • Edited by Imb-hb Thursday, April 12, 2018 8:57 PM Added
    • Proposed as answer by Terry Xu - MSFT Friday, April 13, 2018 2:54 AM
    Thursday, April 12, 2018 8:55 PM
  • You'll find examples in SaveDemo.zip in my public databases folder at:


    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

    The principle purpose of this little demo file is to illustrate how to enforce the saving of a record via a command button on a form, but it also illustrates the validation of 'required' controls at both control and form level.  This should also be done at table level of course, by setting the Required property of such columns to True, and, where appropriate, the AllowZeroLength property to False.

    Ken Sheridan, Stafford, England

    Thursday, April 12, 2018 10:21 PM