Validation rules in the table design properties are known


Table

Start by making a table with the usual Names and addresses. Make sure you use the appropriate field types and sizes. There is no need for input masks or primary keys. Here are the fields to include:

Last
First
Street
City
State
Zip
Date of Birth
Check- In Date
Check-Out Date
E-mail
Comments
Photo

Make sure to set the date fields to use Date Picker. Comments field should be Memo/Long Text Type and Photo should be Attachment Type.

Add a Validation Rule for Date of Birth so no one under the age of 18 can be added to the table. Hint: subtract the DOB from today's date and divide by 365.25 (watch the parentheses and pay attention to the arithmetic "order of operations" ) Do NOT use any functions here or in the queries that we did not discuss. (More below on using "today's date" function)

Make a Validation Rule to ensure that the Check Out Date is later than the Check In Date.

Queries:

Make a select query with a calculated field for age, to list only guests between 20 and 40 years of age! Make sure to enter a range of ages in your table so you have something to display.

Make a Parameter query that allows the user to choose which birth month to display. So when the user is prompted for a birth month, they might type in 3, for March, and only the records which have a Date of Birth in March, will display.

Make an Update Query that will add the phrase "Free Champagne for this Preferred Guest" to the Comments field, but only if the guest stays for 8 days or more.

Make a form similar to this one:

Make a Report

How it's done:

Some simple computer arithmetic that you need to calculate age:

As in Excel, the function NOW() indicates the current day and time as supplied by the internal computer clock. This is very handy for date arithmetic that needs to be constantly updated. NOW() if often used in calculations to to add days to an order date, or a subtraction with a birth date to calculate age.

If you were doing this in a query (making a calculated field for Age (you are asked to do this above) you could right-click the column, choose Properties and set the format to Fixed, and Decimals to 0, to avoid long decimals after the number. Just a thought.

Record Level Validation

Validation rules in the table design properties are known as column level as you can only reference one field, such as Amount > 100. (you did this with the Units Field - remember?).

To set a Record Level validation, it's a bit different. First a record level validation is when you need to compare two fields in the same table, such as, Amount Paid must be less than or equal to Amount Owed, or some such thing.

Since Amount Paid and Amount Owed are both fields in the same table, the validation rule comparing them has to be written differently than usual. In a different place.

In Table design view, you must right-click the table (anywhere is fine) and select properties. In the properties panel on the right, enter the validation rule in the Validation Rule slot you see there.

Request for Solution File

Ask an Expert for Answer!!
Database Management System: Validation rules in the table design properties are known
Reference No:- TGS01347412

Expected delivery within 24 Hours