Welcome back to our course on Access 2013.
In this section we’re going to start to take a look at forms and forms are the primary
means by which we allow users to interact with our database.
During most of the course, so far we’ve been looking at tables and table design and
entering data directly into the tables in that general spreadsheet style, the Datasheet
View as we call it in Access.
But that’s not really a good way to get users in general working with the data in
a database.
It’s far too dangerous.
It doesn’t present the data in a way that’s easy for users to understand and generally
speaking it’s asking for trouble really.
So what we do is to provide forms and with those forms not only can we control what people
are able to do with the database but we can do many other things as well, such as perform
calculations and checks in the background.
We can fire those events which I mentioned earlier on whereby when we change a piece
of data in one place, it causes something else to happen elsewhere in the database.
So forms are a great way of both protecting the database and perhaps more importantly
helping users to get the best out of the use of the database.
Now as we’ll see there are a few ways of creating forms in Access 2013 and I want to
start with a very simple case.
What I’m going to do is to open the genre table, so just double click to open the genre
table and then I’m going to minimize the Navigation Pane, then I’m going to the Create
Tab and then there’s a Forms Group.
Now in the Forms Group there are really four ways, or four main ways I should say, of creating
a form.
There is this button, Form, where you create a form that lets you enter information for
one record at a time.
There’s form design which gives you a blank form and then lets you layout the form in
exactly the way that you want by adding controls to the form in exactly the positions you want.
This one, blank form, which creates a form with no controls or formatting whatsoever
and lets you start literally from scratch, and then there’s also a Form Wizard and
we’ll look at the Form Wizard a little bit later on.
That’s a very helpful way of creating forms, but given that the way it does things may
not quite agree with the way you like to do things.
Sometimes the Form Wizard, although it looks as though it’s going to save you time, can
actually take you longer to create forms and this probably particularly the case when you’ve
been using Access for a while and created quite a few forms.
Now the other on there, the navigation form, is very often a feature that you’ll use
as what I would call the front end to the database.
It’s the way that you control in the broadest sense what users are able to do in your database
and we’ll be looking at a navigation form much later on in the course.
Now the drop down here with more forms gives us access to modal dialogs, split forms, etc.
and we’ll come back to a couple of those later on as well.
The first thing I want to demonstrate is the Form Wizard.
So in the Forms Group I’m going to click on Form Wizard.
It’s actually a sequence of dialogs.
Given the table that is selected which is the genre table at the moment there is only
one available, field.
All of the available fields are here but there is only that one, genre.
So I choose the available field or fields that I want on my form and click on the arrow
there and that becomes one of the selected fields that will appear on this form.
Having chosen the fields that I want, in this case there is only one, I click on Next and
then I’m given a choice of four layouts for a form.
Now datasheet layout, the third one, is pretty much the same as a datasheet.
You can try that yourself, but it doesn’t really help us very much.
There are some situations where it’s useful as we’ll see later on.
But the one I want to demonstrate first is a very straightforward form.
It’s tabular form.
And what happens in a tabular form is that we have a table with the fields that we’ve
chosen across the page.
So the first field is one column, the second field is another column, and so on.
So having chosen tabular layout, click on Next, now we’re asked to give our form a
name.
The prefix I use on form names is F-R-M and I’m going to call this frmGenreTabular for
the moment just so we can remember what it is.
Now when I click Finish, I get a choice here.
I can either open the form to view or enter information or I can modify the forms design.
I’m going to open the form, click on Finish, and there is my form.
Now it may not look very different from a datasheet but it’s actually really quite
different.
We have still one row per record and the tabular, the tables in this case, there is only one
column.
The column is genre and the genre we’ve got are Action, Adult, Adventure, and so on.
Now what the Form Wizard has done is to look at our table definitions and to decide how
wide to make these fields.
Now we changed the size of this field to 30 characters maximum and it’s pretty much
allowing for 30 characters maximum.
Clearly looking at the data that’s there already, that field is probably a bit too
wide but never mind.
If I wanted to change any of the data in this using this form, I could literally just click
in a field and delete, type, whatever I want to do.
I get the familiar pen symbol in the left there, the little icon that tells me I’m
changing that field and I can either click undo or press Escape if I want to undo any
changes.
When I insert new records, they’re always inserted at the end.
I’ve even got a set of navigation controls down here.
So if I want to go to new record, new blank record, click there and I can add a new genre
at the end and that’s where it will appear.
Now that’s a pretty straightforward form updating genre and you probably look at it
and think, “Well, that’s not really giving me anything over Datasheet View” and to
some extent that’s true.
But at the moment I’m just trying to look at the overall features of forms.
So let me close that form and I’m going to close the genre table as well and I’m
going to open up the Navigation Pane again and we’ve now got a new section in our Navigation
Pane for forms.
Don’t forget if we’re interested in one particular type of object, we can collapse
the list for another object like tables and we’re just concentrating on forms at the
moment.
Now with the form we’ve just created, I’m now going to go into Design View.
I’m going to take a look at it in Design View because in Design View it looks like
a very different thing altogether and you can see the structure of that form.
In fact, at the moment, the structure has really three parts.
There is a header, there is a detail section, and there is a footer.
So we’ve got a form header and a form footer and they will be common features in forms,
headers and footers.
Now this particular form doesn’t currently have a footer but don’t worry about that.
We’ll come back to that in a while.
The detail section is very important because this is the part that is repeated for each
record in our table.
So basically at the moment the detail section is one field; it’s the genre field and you
can see there the size of the field.
Now what I want to do is to look at the properties of that field.
If I click just on the edge of that field, you’ll see that the field now has a sort
of orange border around it.
That indicates that the field is selected.
If I right click right down at the bottom, you may just about see it; it says Properties
and that opens up a property sheet on the right here and this contains the properties
of that one field.
Now as you can see there are a lot of properties.
You can do an awful lot of things with a field on a form in Access and the first time you
see that it probably looks a bit scary.
But we’re just going to concentrate on a couple of the main points to begin with.
Now one thing to be careful of whenever you’re looking at properties on forms is to make
sure that you have the right object selected.
Sometimes you’ll have an individual field selected as we have here.
Sometimes you might have the whole form selected.
You can always check your selection over on the top here because it says the selection
type in this case is a textbox and the particular control we’ve got there holding the text
for the genre of the field is a textbox.
It’s one of the simplest controls you’ll see on a form.
By the way, let me just move the Navigation Pane out of the way there.
Now let’s look at some of the other properties of this particular textbox.
It has a name.
It’s called Genre.
It gets the same name as its next property control source.
What this means is given the table or query that this form is being populated by, so where
the data’s coming from, which field goes in here.
The field that goes in there is the genre field.
We then have format.
Now we talked about format in relation to tables earlier on and I also mentioned that
you don’t necessarily make all of your definitions in your table design.
Sometimes you may want to do some of your definitions in your forms.
And this will apply to things like input mask, format, etc.
Now most of the other properties we’ll either come back to later or they’re a little bit
detailed.
But just to give you one or two further examples down there, you have a text align option here
of general.
You could change that if you wanted to.
If you, for instance, wanted the text here to be right aligned on this particular form,
you could select right align here instead of leaving it at general.
There are many other properties some of which we’ll be looking at later on.
Now this is a very long list of properties and in fact we are looking at the All Tab
here which lists all of the properties of that field.
There are tabs here whereby the properties are categorized.
So properties associated with the format are on that tab, with the data are on that tab,
with events are on that tab.
So for example, what happens if the user double clicks on that field and then we have a category
of other as well?
So when you’re used to using these properties you’ll probably be able to go more quickly
to a particular property that you might need in a given situation.
Now when I right clicked on that field before, you may have noticed that one of the options
was not properties but form properties; let me just click on form properties down at the
bottom and now what I have selected is the whole form.
You can see selection type is form and what we see is the properties of this form.
Now we’ve currently got the other tab selected.
Let’s just select the All Tab and what we can see is, first of all, the record source.
Let me just pull this over.
Note we can make that property sheet bigger; make it a bit easier to read what each of
the properties are.
The record source is the table genre, tblGenre.
The caption on the top is F-R-M-GenreTabular.
Why don’t I change that caption and say.
There I think that’s probably better.
Is it a pop up form?
No.
Is it modal?
No.
Now the significance of modal will become apparent when I talk about that a bit later
on, but basically a modal form is one where you have to deal with it and click OK or cancel
it before you can do anything else.
That’s rather oversimplifying, but that’s the general principle.
The default view if this form is continuous forms.
That’s very important.
That’s the thing that makes it work in the way that it did, like a datasheet if you like.
You scroll through all of the records and that’s because it’s a continuous form.
Now there are various other properties and several of those we’re going to look at
in detail later on.
But it’s very important, as I said before, to know whether you’re looking at the form
or one of the fields on the form.
So let’s close this property sheet.
Let’s close the form, saving changes, open up the Navigation Pane again, and let’s
just open our form again.
You can see the revised caption at the top there, the one that I typed in.
Don’t worry too much about what’s in the heading because we’re going to tidy up the
heading later on.
But as you can see, the form works in the way that it did before and the continuous
form part of it is the bit that means that we scroll continuously through all the records
in that particular table.
In the next section we’re going to look at another type of form so please join me
for that.