Microsoft Access

Hopefully at the workplace you will use a full RDBMS such as Oracle, MySQL, MariaDB etc. But you can run SQL commands on Microsoft Access to at least get some experience using them.

Creating a database

Launch Access. From the Home screen click the Blank database to start.

Example Access home screen
Example Access home screen

Give the database a name when prompted.

Access then creates a database with a new table to edit already made.


Add columns

Access has already added a column to work as a key. This is a number field that automatically increments each time you add a record.

Click the dropdown beside “Click to Add”. Here you can see the data types available for the attributes.

Example to add a column
Example to add a column

Access datatypes

DatatypeDescription
Short textUp to 255 characters with no formatting.
Long textUp to approximately 65,000 characters. Allows html and other formats.
Rich textA short cut to a long text field with formatting options present.
NumberIntegers that range from -32,768 to 32,767.
Large numberIntegers that range from -2,147,483,648 to 2,147,483,647.
Currency15 digits to the left of the decimal point and 4 digits to the right. Not rounded off.
AttachmentStores files in the record. Not all extensions allowed.
Data and time extendedIncreased precision and formatting options

Common Access datatypes

Access defaults Number fields to use integers. If you want to use floating point numbers you will need to alter the Field Size in the table’s Design View before adding data.


Foreign keys

Use a number field for the foreign key because all the primary keys in this exercise are the automatically added number fields.

Close any open tables that you want to link together.

Click on the Database Tools menu then choose the Relationships icon.

Relationships button
Relationships button

Click and hold on the ID under Driver, drag the mouse until you are over the DriverID in the link table and release.

In the popup box tick the checkboxes so that deleting the Driver will also delete the matching items in the link table. Click Create and repeat for the VehicleID link. Save the Relationships tab.

Example relationships screen
Example relationships screen

Forms

To insert data in Access you use forms.

Click on the Create menu and choose Form Wizard from the ribbon.

Example forms wizard
Example forms wizard

Choose the columns that you want in the form. This will usually be all of them except the ID as that is automatically added by the system.

Then choose whichever layout you prefer.

Give the form a name the choose to either start adding data or change how the form looks. Choose the first option for now.

Example forms wizard final screen
Example forms wizard final screen

Forms aren’t just about adding data. You will see existing data too and can edit it.

If you are adding a new record, then use the arrows at the bottom of the screen to move to the end of the records until you are at a blank one.

Example form screen
Example form screen

Foreign keys have to exist before they can be used. A way to do this in forms is the combo box. Right click on the form and choose to open it in either Design or Layout view. Add a combo box from the ribbon.

Combo box button
Combo box button

In the popup wizard choose the first option to get the value
from another table. Choose the table that foreign key is from.
Choose the columns that you need, the ID plus some
description that makes more sense to the user. Choose how to
order the results in the next screen.

Leave the hide ID checkbox ticked and store the value in the
foreign key field. Finally give it a Label.

Example combo box wizard
Example combo box wizard

Making it look nicer

Click on the combo box in the form and then view the Properties pane to the right. Under Data -> Row Source you should see something like:

SELECT [Vehicle].[ID], [Vehicle].[Number Plate], [Vehicle].[Manufacturer], [Vehicle].[Model] FROM [Vehicle] ORDER BY [Manufacturer], [Model], [Number Plate];

Change this to something like:

SELECT [Vehicle].[ID], [Vehicle].[Number Plate] & " " & [Vehicle].[Manufacturer] & " " & [Vehicle].[Model] FROM Vehicle ORDER BY [Manufacturer], [Model], [Number Plate]; 

What you’ve done is combine the descriptive results into one column. Now click on the Format tab in the property pane. You want to change the column count from 4 to 2 and alter the width of the new single column.

Example before change
Example before change
Example after change
Report a Glow concern
Cookie policy  Privacy policy

Glow Blogs uses cookies to enhance your experience on our service. By using this service or closing this message you consent to our use of those cookies. Please read our Cookie Policy.