databasedev.co.uk - database solutions and downloads for microsoft access

Unbound Forms

What is a unbound form in Microsoft Access?

Basically it is a form that is not bound to any database table or query. You can usually determine if a form (or a control on a form) is bound by looking at its record source property which will either be bound to a Table, Query or SQL String. Also if you look at each control on the form you will find that each control has a Control Source, which is derived from the field names made available in the Record Source. A bound form is easier to create and requires minimal programming (if any). It allows for rapid application development since Microsoft Access is designed to make application development fast and easy. An unbound form on the other hand requires a lot of programming, BUT gives you near total control over how your application is going to work. This in some cases outweighs the numerous benefits offered by bound forms.

In the first installment of the series on unbound forms in Microsoft Access, we are going to take a look at how to create a unbound form, but first let’s create the database from which we will get our data.

The Database

The contacts database has one table called contact with the following fields:

Field Name Data Type
cid (Primary Key) AutoNumber
name Text
address Text
email Text
occupation Text
age Text

Copy and paste or import the following sample data into the contact table:

1,"Axaro Dausab","255 Amite Street","ax@dausab.com","Market analyst","20"
2,"Khagu Noabes","58 Xamiseb Road","khagu@noabes.com","Medical Student","22"
3,"Dantago Nuseb","2 Nuseb Street","dan@nuseb.com","Medical Student","22"
4,"Phuna Noabeb","2 Nuseb Street","phuna@noabeb.com","Web Designer","30"
5,"Aribasen Seibeb","58 Xamiseb Road","areez@seibeb.com","Researcher","35"
6,"Zion Maletzky","58 Xamiseb Road","zion@maletzky.com","Web Designer","20"
7,"Leidago Noabeb","277 Mudi Road","leidago@noabeb.com","Web Designer","30"
8,"Amite Itheke","26 Shanke Road","am@itheke.com","Market Analyst","40"
9,"Amire Ganuseb","23 Ganuseb Road","amire@ganuseb.com","Fashion Designer","45"
10,"Dinashange Develo","40 Develo Road","dina@shange.com","Journalist","23"

If you want to use your own data it is fine, but for the sake of facilitating things I would recommend using the sample data.

So the structure of your contact table should now resemble something like this:

The Contact table in design view

And with sample data it should look something like this:

The Contact table, containing sample data.

The Forms

We are going to have two forms that we will use to manipulate data contained in the above table. The first form will enable us to view the data in the table. It has the following design:

Five text boxes, one label, one button and a listbox (linked to query) appropriately named after the columns in the table;

  • txtname – Holds the name of the contact
  • txtage – stores the age of the contact
  • txtemail – stores the email address of the contact
  • txtoccupation – holds the occupation of the contact
  • lbaddress – describes the address of the contact
  • txtid – stores and displays the auto created ID of the contact

The Contact Form in design view

The form has two sections, the first of which enable us to go through a list of different contact names and the second part shows all the different details of the selected contact name:

The Form

The list box that contains the names of the contacts is linked to a query that retrieves all the data from the contact table using the following sql:

SELECT * FROM contact;

The query is stored as “getdata” under the queries tab. Once you click on any of the names on the list, the other details of the contact is then displayed in the appropriate text boxes. Also, next to the list box in the above image you will notice the number seven, which is the auto generated id of the contact, which we will use later for searching and updating.

In the next installment we will look at how to add new contacts to our table using an unbound form » Adding Data with Unbound Forms in Microsoft Access

Download the database used in this article

The Author

Leidago !Noabeb is a computer programmer based in Namibia. He has worked with both opensource and Microsoft technologies for over seven years and specializes in writing communications software. He has made many contributions to various online websites dedicated to web development. He can be reached at: leidago [at] googlemail.com