WEBVTT
Kind: captions
Language: en

00:00:01.170 --> 00:00:16.099
Sometimes, you may decide that you want to
add or modify fields in your tables.

00:00:16.099 --> 00:00:19.751
Access makes it easy to do this, although
there are some important things that you'll

00:00:19.751 --> 00:00:21.590
need to consider.

00:00:21.590 --> 00:00:25.230
There are three different rules that you can
apply to control the type of data that the

00:00:25.230 --> 00:00:27.019
fields can accept.

00:00:27.019 --> 00:00:32.160
And these are data types, character limits,
and validation rules.

00:00:32.160 --> 00:00:37.280
To get started, make sure that you have a
table open.

00:00:37.280 --> 00:00:40.149
I'm using the Customers table.

00:00:40.149 --> 00:00:44.309
We're going to scroll all the way to the right
until you see the blank field that says Click

00:00:44.309 --> 00:00:46.049
to Add.

00:00:46.049 --> 00:00:49.379
And when you click on it, you'll see a list
of all of the data types that you can choose

00:00:49.379 --> 00:00:51.469
from.

00:00:51.469 --> 00:00:55.940
Text is the default option, and this is the
type that you'll use for regular text, such

00:00:55.940 --> 00:00:58.499
as a person's name or address.

00:00:58.499 --> 00:01:02.199
You'll also use it for numbers that aren't
used in calculations, like a phone number

00:01:02.199 --> 00:01:04.140
or zip code.

00:01:04.140 --> 00:01:08.680
For any numbers that you might want to do
calculations with, you'll need to choose Number.

00:01:08.680 --> 00:01:12.880
For example, we would use this for the quantities
of an item that were sold.

00:01:12.880 --> 00:01:16.350
If you're dealing with money, then you'll
choose Currency.

00:01:16.350 --> 00:01:19.780
And if you choose Date &amp; Time, then when you're
editing that field, you'll see a calendar

00:01:19.780 --> 00:01:22.880
icon, which you can click to select a date.

00:01:22.880 --> 00:01:28.340
But in this case, I just want a simple Yes
or No answer, so I'll choose this one.

00:01:28.340 --> 00:01:31.689
And this adds a checkbox for each record.

00:01:31.689 --> 00:01:33.890
Then you can type in the name of your field.

00:01:33.890 --> 00:01:38.869
I'm going to name it "Add to Mailing List?"

00:01:38.869 --> 00:01:42.890
Then I'll resize this field.

00:01:42.890 --> 00:01:48.000
Now we can just check each customer who wants
to be on our mailing list.

00:01:48.000 --> 00:01:53.689
And you can also click and drag the name to
move the field wherever you like.

00:01:53.689 --> 00:01:57.619
If you decide that you need a different data
type for a field, then you can just select

00:01:57.619 --> 00:02:04.650
it, and then go to the Fields tab… and click
the Data Type drop-down arrow.

00:02:04.650 --> 00:02:09.509
I'm going to change this to text so I can
add additional information in this field.

00:02:09.509 --> 00:02:13.340
Some of our customers want to receive our
weekly newsletter, but others just want to

00:02:13.340 --> 00:02:15.480
hear about our special events.

00:02:15.480 --> 00:02:19.670
Now you should be very careful about changing
the data type because it is possible to lose

00:02:19.670 --> 00:02:23.530
some of your data if you change it to the
wrong type.

00:02:23.530 --> 00:02:27.370
In some fields, you may want to narrow down
the data even further by adding a character

00:02:27.370 --> 00:02:28.370
limit.

00:02:28.370 --> 00:02:31.090
And you can only do this with text fields.

00:02:31.090 --> 00:02:35.760
For example, we want all of the states to
be formatted the same way, so we're only using

00:02:35.760 --> 00:02:38.290
the two-letter state abbreviations.

00:02:38.290 --> 00:02:43.069
If some of the records say NC, and others
say North Carolina, then Access won't know

00:02:43.069 --> 00:02:48.670
to group them together—which means our sorts,
filters, and queries may not work right.

00:02:48.670 --> 00:02:52.010
In the Fields tab, find the field size box.

00:02:52.010 --> 00:02:59.580
The default field size is 255 characters,
but I'm going to change it to 2.

00:02:59.580 --> 00:03:02.750
And you may get a warning message here, so
if you're sure you want to change the field

00:03:02.750 --> 00:03:05.769
size, click Yes.

00:03:05.769 --> 00:03:09.689
In this case, setting a character limit isn't
quite good enough because somebody could still

00:03:09.689 --> 00:03:15.000
type a two-letter code that's not a real state
(for example NX).

00:03:15.000 --> 00:03:18.850
To prevent that, we need to be a lot more
specific about what types of input this field

00:03:18.850 --> 00:03:20.069
will accept.

00:03:20.069 --> 00:03:23.310
And we'll do that by adding a validation rule.

00:03:23.310 --> 00:03:29.390
In the Fields tab, go to the Validation command
on the far right… and select Field Validation

00:03:29.390 --> 00:03:30.660
Rule.

00:03:30.660 --> 00:03:36.540
Here, I'm going to type each state abbreviation
in quotation marks, and I'm separating each

00:03:36.540 --> 00:03:39.530
one with the word "Or."

00:03:39.530 --> 00:03:43.180
And this may take a while.

00:03:43.180 --> 00:03:48.650
So this expression is just looking for exact
matches, but if you want, you can create validation

00:03:48.650 --> 00:03:52.780
rules using the same syntaxes that we talked
about in the query lessons.

00:03:52.780 --> 00:03:56.790
For example, you could use the Like syntax
to set a validation rule that only allows

00:03:56.790 --> 00:03:58.590
text that ends with "cake."

00:03:58.590 --> 00:04:03.170
Or, if you're using numerical values, you
could use greater than to make sure that none

00:04:03.170 --> 00:04:07.290
of our quantities are negative.

00:04:07.290 --> 00:04:10.939
When you're done, click OK.

00:04:10.939 --> 00:04:15.750
Whenever you create a validation rule, it's
important to create a validation message.

00:04:15.750 --> 00:04:19.880
And this option is also under the Validation
command.

00:04:19.880 --> 00:04:23.470
This message will pop up whenever somebody
tries to type in something that doesn't follow

00:04:23.470 --> 00:04:25.230
the validation rule.

00:04:25.230 --> 00:04:29.040
The message should briefly describe the rule,
so that the user can then make the necessary

00:04:29.040 --> 00:04:30.040
corrections.

00:04:30.040 --> 00:04:36.840
In this case, I'll just mention that it needs
to be a 2-letter abbreviation.

00:04:36.840 --> 00:04:41.010
Now you won't need to add a character limit
or validation rule to all of your fields,

00:04:41.010 --> 00:04:44.790
but you can add one or both of them whenever
you want to control the types of information

00:04:44.790 --> 00:04:46.190
that your field will accept.

