In our last lesson we learned how to create a form; now we're going to add a record using
the form. The field properties we set earlier still
control the data that is allowed to be entered here.
So for the price field I still have to make sure I enter the price correctly but the one
thing I don't have to worry about in this field is the dollar sign because the data
type we set earlier automatically generates this for me.
The same thing goes for the category field. We must enter one of the categories that we
told Access to accept. So if I enter cars here, I get this message.
We want to make sure we enter a category that's actually in the book store.
But what if we don't have all of the category names memorized? An easier way to make sure
we enter a valid category is to create a drop down list that lets us choose which category
the book belongs to. Right now we don't have a drop down list so
we have to type in a category name. Let's just type in Fiction.
It's a good idea to save the information you enter or edit in a form because sometimes
information will only show up in the table after you've saved it.
Let's take a look at our books table to see if our information saved.
If the information doesn't show up in the table you may need to click the Refresh All
button. As I said before the form is just another
way to enter data into a table. Since the form is supposed to be an easier
way to enter data, we'll fix that Category field on the Books form by making a drop down
list. Let's look at the Books form in Design view.
To make a Category drop down list we'll select List Box or Combo Box from the Controls group
under the Design tab. List Box makes a list where you can see several
choices in a list and a Combo Box makes a nice drop down menu.
I'm going to choose the combo box command from the Controls group.
When I move my mouse over my form, a crosshair with a combo box icon appears.
Since we want to add the list to the category field, I'm going to left click and draw a
box right on top of the text box. I want to make sure I line it up just right!
I could have deleted the text box but it would have changed the layout of my form.
When you release your left mouse button, this combo box wizard appears.
We have three options to choose from. We're going to choose the second option that
lets us type in our own values. This is a good choice for us, since the categories
in our store are pretty constant, we don't have too many categories and we won't be adding
new categories very often, so this option makes sense for us.
Click next to advance. On the second screen, we're going to type
in our category names in this area that looks like an Excel spreadsheet.
We only need 1 column of choices for the Category field but if we had more we could change this
number here. Click Next to advance.
From this part of the wizard we'll choose the second option.
This option tells Access that we want to save the value that the user selects from the category
list within a field in the table. Next we select Category because that is the
field we want to populate. So when a user selects one of the choices
in the Category drop down list it saves that choice in the Category field of the table.
On the next screen we can give our combo box a name.
This field is unnecessary so I'm going to leave it as is and delete it from Design View.
Looks like we're finished. If you look closely you'll see this box to
the side of the drop down list. As I said before, it's not necessary so let's
delete it by selecting it and deleting it. If I don't delete it, it will show up on our
form and it's just an eye sore and somewhat of a distraction.
Let's go to Form View so we can see what the drop down looks like.
If I click on the drop down arrow I can see all of the categories I entered.
So now when I enter a record I can just click here to input the category. Once the data has been entered in the Form,
save it. You may need to refresh the actual table to
have the data show up there. I showed you how to enter a record using a
form but you can also edit an existing record using a form.
In our last lesson we learned how to use Find and Replace to change information in the Customers
table - well it works the same way with a form.
Right now I'm going to the Navigation Pane and open the Customers form.
I'll go to the navigation pane and open the Customers form.
Let's find Kiara again. This time I want to change her zip code.
Great, I found the record. Now on my form I'm going to go to the zip
code field and change it. Let's save our changes and go back to the
table and see if it's there, and if not we'll just hit refresh.
I told you forms made things easier! In the next lesson, you'll learn how to create very
specialized buttons on forms to control even more of what your user can enter.