Creating a Menu Form
way to make use of forms is to create a menu containing buttons
which you can click to enter other forms and queries. If you
set this form as your startup form then it will appear as soon as
the database is opened.
a menu form, it is best to use Design view. When you have
started a new form in Design view you will see a screen like the
the toolbox which appears, if you want to know what each tool is
you can hold your cursor over the icon and a description will appear.
We are going to use the Command Button control to put some
buttons on our menu which will launch other forms and queries.
a button, click on the Command Button control icon on the toolbox
and you will see your cursor change. Click on the grey area
of the form and drag out a rectangle for your button as shown below,
you can always resize it later if necessary.
as you have dragged out the button you will see the window below
chosen the Form Operations category and the Open Form
action as we are going to use this button to open our Employees
form. When you have highlighted the actions you want to perform,
click the Next button and you will see the window
the form you want to open and click the Next button
to proceed to the window below.
gives you the chance to open the form with all the records or to
filter out certain records. You will not be able to use the
first option unless you are able to link records in your forms,
we just want to open the whole form. When you click the Next button you can choose whether you button has a text
description on it or a picture as below.
put the text 'Employees' on our button. Click the Next button and you can give your button control a name
Finish button and you will see the completed
button on your form.
want to see the code behind this button, click your right mouse
button on the object and choose Properties
from the menu which
appears. Click on the Event tab of the Properties window and you
will see the information below.
cursor on the On
Click line and then
click the box containing three dots to see the code of the Event
Procedure. This is the code of this procedure:
Option Compare Database
Private Sub Employeeformbutton_Click()
On Error GoTo
Dim stDocName As String
stLinkCriteria As String
stDocName = "Employees"
DoCmd.OpenForm stDocName, , , stLinkCriteria
This will open the Employees
form to display one record at a time. If you want to open
the Employees form in Datasheet view so that you can see all the
Employees at once you need to change the DoCmd OpenForm as follows:
stDocName = "Employees"
DoCmd.OpenForm stDocName, acFormDS,
Notice the acFormDS parameter
which has been added, this forces the form to open in Datasheet
Close the Visual Basic window
and then close the Properties window. Save your form by clicking
the floppy disk Save icon and you will be asked for a name as below.
Your menu form is now finished.
If you want to set this form as your startup form click here to see how to enter the Startup settings.
Click here to
return to the Access index.