WEBVTT
Kind: captions
Language: en

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

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

00:00:17.840 --> 00:00:19.660
need to consider.

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

00:00:23.320 --> 00:00:25.100
fields can accept.

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

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

00:00:35.090 --> 00:00:37.980
I'm using the Customers table.

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

00:00:42.120 --> 00:00:43.870
to Add.

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

00:00:47.210 --> 00:00:48.579
from.

00:00:48.579 --> 00:00:53.760
Short text is the default option, and this
is the type that you'll use for regular text,

00:00:53.760 --> 00:00:56.490
such as a person's name or address.

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

00:01:00.180 --> 00:01:02.129
or zip code.

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

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

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

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

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

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

00:01:26.420 --> 00:01:29.670
And this adds a checkbox for each record.

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

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

00:01:37.289 --> 00:01:41.649
Then I'll resize this field.

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

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

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

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

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

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

00:02:12.099 --> 00:02:14.250
hear about our special events.

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

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

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

00:02:25.730 --> 00:02:26.730
limit.

00:02:26.730 --> 00:02:29.670
And you can only do this with text fields.

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

00:02:34.349 --> 00:02:36.890
the two-letter state abbreviations.

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

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

00:02:47.260 --> 00:02:50.600
In the Fields tab, find the field size box.

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

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

00:03:01.340 --> 00:03:04.390
size, click Yes.

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

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

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

00:03:17.470 --> 00:03:18.689
will accept.

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

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

00:03:28.020 --> 00:03:29.280
Rule.

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

00:03:35.170 --> 00:03:38.150
one with the word "Or."

00:03:38.150 --> 00:03:42.439
And this may take a while.

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

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

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

00:03:56.040 --> 00:03:57.840
text that ends with "cake."

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

00:04:02.430 --> 00:04:06.540
of our quantities are negative.

00:04:06.540 --> 00:04:10.189
When you're done, click OK.

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

00:04:14.999 --> 00:04:19.150
And this option is also under the Validation
command.

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

00:04:22.720 --> 00:04:24.470
the validation rule.

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

00:04:28.550 --> 00:04:29.550
corrections.

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

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

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

00:04:44.180 --> 00:04:45.590
that your field will accept.

