COSC 3P32
Lab Activity
The main point of this activity is to get you started in learning the basics of how to build
Microsoft Access Forms which are linked to a PostgreSQL database management system.
Prior to starting the tutorial, you need to make sure that all of the appropriate tables are
defined in your PostgreSQL database. You should use the scripted population file,
populate_psql.txt which is available on the course website. Read this file first so that you are
aware of what it does. Then once you are ready log into Sandcastle (using Putty or and SSH
client), start the PostgreSQL client by running `psql username` (where username is replace
with your own username) and type ‘\i populate_psql.txt’ at the prompt (populate_psql.txt
needs to be in the same directory as you started psql).
You will link to these tables using Access. Start Access then follow these steps to connect with
PostgreSQL:
• Start with a blank database
• Click on External Data tab
• Navigate to the Add Data Source -> Other Sources -> ODBC Database
• Click on ODBC database and in the pop-up window, select “Link to the data source by
creating a linked table”
• In Select Data Source pop-up window, click on Machine Data Source and select COSC, then
click OK
• At this point you will need to add user name, PostgreSQL password and dbname (note that
your dbname is the same as your username)
• When asked which tables to link, select all then click OK.
Before you start building the forms you must define the relationships within Access (it does not
get foreign key information through the ODBC interface). On the left side, under All Access
Objects, you will see a list of your tables. Click on the Database Tools tab, then select
Relationships. Drag the tables onto the sheet and organize their relationships by using Edit
Relationships and selecting the appropriate fields in each table.
The tutorial you will follow is provided by Microsoft at the following location:
https://support.office.com/en-us/article/create-a-form-that-contains-a-subform-a-one-to-
many-form-ddf3822f-8aba-49cb-831a-1e74d6f5f06b
You should read the entire tutorial for full information, but the specific section on which you
will concentrate is “Create a form containing a subform by using the Form Wizard”.
Please note that this online tutorial was written for a different version of Access so some of the
toolbars might be located in other locations.
Once the form is created you will see it (and its subform) on the left under Forms. Click on it to
see the data in the form. The Search field at the bottom of the form allows you to search orders
by ordernum. To move from record to record in orders, click on the ordernum field in orders
and click the arrows at the bottom next to Record; going to the last (blank) record allows you to
enter new data. Data can similarly be added within order_items by clicking on that section of
the form.
You should try to enter new data (in both sections of the form) – as part of this, check to see if
it corresponds to data that already exists in the tables (for example, it should not be possible to
create an order for a customer that doesn’t exist).
If at any step you need help, remember that your TA is available for exactly this purpose!
Note: this lab activity is primarily intended to introduce you to the environment you will be
using for your project. Each group should be sure to allocate appropriate time to continue to
investigate this environment for themselves, to evaluate which features they wish to include in
the second part of their project.
For more related information, you can also review:
https://support.office.com/en-us/article/Add-a-subform-c59387f9-73aa-4082-82cb-
5d29ef04299f
Important reminder about group accounts:
For your group project you must have all of your work placed and presented from your group
account so that the account can be relinquished for marking after the presentation has been
made. The group account application form is located at:
http://www.cosc.brocku.ca/forms/grpacct (there is a PDF copy on the course website) and
must be completed by all your group members and then submitted directly to the instructor. To
make sure there are no unnecessary delays, you should complete this request as soon as
possible.