117
Using the fields
You may wonder why Access writes unbound inside
all the boxes. It means that the box is not bound to any
record in the database. The user may enter something
but it is not automatically stored in the database. Try
this:
11. Close the form. Access asks for its name. Call it
frmFindStay. (We use the prefix frm for forms.)
12. Open it again in user mode. It should now look
like the bottom of Figure 3.1B. This is how the
user would see the form.
13. Try to enter something in the fields. It stays on the
screen, but is it persistent data?
14. Close the form and open it again (in user mode).
All the fields are blank - no data was saved. It was
just dialog data - not persistent data. Click the
command button - nothing happens. It is just a
mockup we have made. (In the next chapters we
will add real data and functionality.)
3.1.2 Adjusting the controls
1. Close the form and open it in design mode. Select
one of the text boxes. Notice the two black han-
dles, one on the label part and one on the text box.
2. Moving and sizing. Point the mouse at the label
handle. The cursor changes to a finger. Try to drag
the label part around. The text box itself doesn't
move. Point at the text box handle and use the fin-
ger to drag it around.
3. Point at the border of the text box. The cursor
changes to a hand. Drag it - both label and text box
should move.
4. Point at one of the sizing handles in the corners or
on the middle of a side. Drag here and the box
changes size.
5. Deleting a control. Click on the text box and click
Delete. Oops - both box and label disappeared!
Undo it using the Undo button or Ctrl+Z.
6. Click on the label part. Notice that now the sizing
handles are on the label part. Click Delete. The la-
bel part disappears.
If you want a label without the text box, select the label
tool from the toolbox and draw a label control.
If you want to add a label to a label-less text box, select
some label, copy it (Ctrl+C), select the text box and
paste the label (Ctrl+V).
7. Moving and sizing with the keyboard. Select a
control, then try moving it around with Ctrl+up,
Ctrl+down, etc. Try moving it with Shift+up, etc.
Now it changes size. This is one way to fine-tune
the positions and sizes. There is no way to enlarge
the picture as you can do in Word and many other
programs.
8. Select several controls at the same time. Either
hold Shift down while clicking on the controls one
by one, or drag a rectangle around them. (All con-
trols touching the rectangle will be selected.) Now
try to move and resize the controls with the key-
board, or drag them with the mouse.
9. Undo. You can undo your last operation with the
Undo button or Ctrl+Z. But only the last! You can
undo all changes since you last opened the form by
closing the form and saying No to saving the
changes. Try it now - you don't want to save the
last adjustments.
Make sure you see all menu items
Access 2000 and 2003 have an annoying feature where
it shows only the last menu items you have used. It
makes it difficult to follow the procedures below. Get
rid of this feature:
10. Right-click anywhere in the menus. Select Cus-
tomize->Options. Access 2000: Look at the
checkbox "Menus show recently used commands
first". Make sure that there is no check mark here.
Access 2003: Look at the checkbox "Always show
full menus". Make sure there is check mark here.
The Format menu and the grid
Open the form in design mode and select a control.
Now look at the Format menu at the top of the Access
window. There are several things here that can help
you design the form:
•
Snap to Grid. If you check this box, all controls
you draw or move with the mouse will snap to the
grid in all four corners. If the grid points are
closely spaced - more than 9 per cm - Access
doesn't show the grid, but snaps to it anyway.
•
Align. You can align the selected controls to the
left, right, etc. or you can align them to the grid.
Only their top-left point is aligned. They don't
change size.
•
Size. You can change the size of the selected con-
trols so that they just fit the data in the control
(matching the chosen font size). Or you can make
them fit the grid in all four corners. Finally, you
can give all the selected controls the same width or
height.
•
Change to ... You can transform the selected con-
trol to another one - with reasonable limitations.
For instance you can turn a text box into a combo
box or vice versa.
3.1.3 Cleaning up the form
You may notice that the form has things in the corners
that we don't want in the final user window (bottom of
Figure 3.1B). The title bar, for instance, holds our pro-
grammer-oriented form name, frmFindStay. It should
be Find Guest. There are also record selectors, naviga-
tion buttons, and space for a scroll bar that we don't
need in the final window. We can correct all of this by
setting properties of the form:
11. Make sure the form is open in design mode. Show
the property box for the form (double-click the lit-
tle square where the rulers meet).
20
3. Access-based user interfaces