0. This rule checks if the gender field value contains the string "male" or "female" and is valid if it does, otherwise it is invalid."/> 0. This rule checks if the gender field value contains the string "male" or "female" and is valid if it does, otherwise it is invalid.">

Home  >  Article  >  Topics  >  How to set gender of verification rules in access

How to set gender of verification rules in access

下次还敢
下次还敢Original
2024-04-10 11:35:23943browse

To set gender validation rules in Access, you need to perform the following steps: Create or open a table and select the gender field to which you want to apply the rule. In the "Validation Rules" field in the "Field Properties" panel, enter the formula: InStr("Male;Female",[Field Name])>0. This rule checks if the gender field value contains the string "male" or "female" and is valid if it does, otherwise it is invalid.

How to set gender of verification rules in access

Gender verification rule setting guide in Access

How to set gender verification rules?

Set up gender validation rules in Access in just a few steps:

Step 1: Create a new table or open the table you want to modify.

Step 2: Select the fields to which you want to apply validation rules. (Usually a gender field)

Step 3: Under the Field Properties panel, find the Validation Rules section.

Step 4: Enter the following formula in the "Validation Rules" field:

<code>InStr("男;女",[字段名称])>0</code>

Please replace "[field name]" with the field's as needed actual name.

Step 5: Click "OK" to save changes.

Rule explanation:

This validation rule uses the InStr() function to check whether the value in the gender field contains "male" or "female" string. If included, the value is valid; if not present, it is invalid and Access displays an error message.

Note:

  • You can customize the error message as needed by entering a message in the Validation Message field below the Validation Rules field.
  • If further validation is required, such as ensuring that the gender field is not empty or contains only these two values, additional expressions can be used.
  • For example, to ensure that the gender field is not empty and only contains "Male" or "Female", you can use the following formula:
<code>Not IsNull([字段名称]) And InStr("男;女",[字段名称])>0</code>

The above is the detailed content of How to set gender of verification rules in access. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn