MS Access : Form Basics in Access 2003/XP/2000/97

What is a form?

A form is an Access object. It generally serves three purposes:

  1. To allow users to perform data entry. Data can be inserted, updated, or deleted from a table using a Form object.
  2. To allow users to enter custom information, and based on that information perform a task. For example, you may want to ask a user for parameters before running a report.
  3. To allow users a method of navigating through the system. For example, you may create a form where a user can select a form to load, a report to run, etc.

Within your Access database, you can view all of your form objects in the Database Window. See below.



Creating a Form

Let's take a look at creating a new form "from scratch".

In the database window, select Forms along the left toolbar. Then click on the New button.



The New Form window should appear. For the purposes of this tutorial, highlight the option called Design View and click on the OK button.



We are now viewing our form in design view. You should see a blank form that looks like this:


Under the View menu, select Properties. You should now see the properties window for the Form object.



Let's take a few moments to explore some of the more commonly used properties for a Form object.


Record Source property

The Record Source property sets the source of the data for the form.

For example, if you want to create a data entry form for the Suppliers table, you would specify Suppliers as the Record Source. This means that if you add a new record in the form, it will insert a record into the Suppliers table. If you modified a record within this form, the data in the Suppliers table would also be modified.

The Record Source property can be set to a table name, query name, or you can build your own SQL statement by invoking the Query builder (ie: clicking on the button with the three dots to the right of the Record Source property)



Caption Property

The Caption property is the value that displays in the title bar of your form.

We'll set the Caption property to display "Add/Edit Suppliers".



Now when we view the Form as an end-user would, it would look like this:



As you can see there is a title bar at the top of the form and it displays the value that we set in the Caption property.


Default View property

The next property that we will take a look at is called the Default View property. If you look at the options available, there are three values that you can choose from - single form, continuous forms, and datasheet.



Single Form

The Single Form option allows a user to view one record at a time in the form. Below, we have a sample form that displays one record from the Suppliers table. At the bottom of the form, you will see (what we call) record selectors. This allows you to navigate from one record to another. You can also see that there are 29 records that you can navigate to in this form.



Continuous Forms

Another option is called Continuous Forms. This option allows you to see multiple records in the form at once. The scroll bar on the right allows you to scroll through the records. At the bottom of the form, you are still given the record selectors to navigate through the records. In this sample, there are 77 records that can be viewed in this form.



Datasheet

Our third option is called Datasheet. This option makes the form appear as if you are looking at the actual table. In the datasheet mode, you can resize the columns or even reorder the columns by highlighting and dragging the column to another location.

You are still given the scroll bar on the right to navigate, as well as the record selectors at the bottom of the form.



Auto Center property

Another commonly used property is Auto Center. This property can be set to either Yes or No. If this property is set to Yes, the form will center itself automatically when it is opened.

If this property is set to No, the form will appear in exactly the same position as you saved it (when you were in Design view).



That covers the more commonly used properties on a Form object.

For the purposes of this tutorial, we've set the Form properties as follows:

Record Source = Suppliers

Caption = Add/Edit Suppliers

Default View = Single Form

Auto Center = Yes


Now, let's build our form.

Adding objects to our form

Our next step is to add objects from the Suppliers table to our form.

Since we've already specified our Record Source, Access gives us some nice features to quickly drop objects onto our form. In the toolbar, there is a button called Field List. It looks like a piece of paper with writing on it. Click on this button so that it is selected.



Once you do this, you should have a small window appear on your screen that looks like this.



This window lists all of the fields that are available for your form to use, based on the Record Source property.

To add one of these fields to your form, highlight the object in the window, and then drag it to the location in the form where you wish to add this object.



We've chosen to add the following three objects to our form.



The first thing that you'll probably want to do is resize your objects. To do this, click the object that you wish to resize.



You should notice small black boxes around the perimeter of the object. Move your mouse pointer over one of these "resizing boxes". When your mouse pointer displays double-headed arrow, hold down the left mouse button and drag the object to the desired size.

If you wish to move the object, move your mouse pointer until it displays a hand icon. Then hold down the left mouse button and drag the object to the desired location.



Viewing your form as a user would

Now that you have finished placing your objects on the form, you will want to view the form as a user would. This whole time you've been editing your form in Design view.

To view your form, select Form View from the drop-down list on the toolbar. See picture below.



Our form looks like this:




Saving form

One final step is to save our Form object. You can do this at any time during creation of the form, but for the purposes of this tutorial, we are saving this as our last step.

Click on the Save button in the toolbar. (disk icon)

A "Save As" window should appear as follows:



Select a name for the form and click on the OK button. We usually always prefix our form name with "frm". It is just a naming convention that we use.

Now when you return to the Database Window, you will see your form in the list.



Congratulations! You've now created your first form.