You need to use what you just learned and what you learned in the previous project, and maybe learn a little more. The exercises with databases will require more steps than in the other lessons!
Complete all parts of the following exercises. Don't forget to backup your Class disk when you have completed the exercises or whenever you stop for the day and saved a document along the way.
What you will do: | Import data and objects from external sources in different formats Create relationships Correct imported queries Export results of a query |
[You will use the database created here in the exercises for Forms and Reports also.]
Some years ago when I was the Service Unit Manager (head local volunteer), I created a database for managing the Girl Scout troops and leaders in our service unit. I have reduced the number of records and objects and have somewhat normalized the database for use here. I have learned more over the years about how this should have been done to start with!
You will import data in various formats to create the tables, so you won't have to enter many records. (Hurrah!) I actually took my working copy of the database and exported the objects that you will import. The process of exporting changed some of them! You will see what kinds of difficulties that creates! It is fairly common to share tables with others or to purchase names/addresses list in various formats. You need to know what kinds of issues that can raise.
Disclaimer:
All of the names, phone numbers, and addresses are fictional and any
correspondence to actual persons is coincidental. Girl Scouts of the
USA has not approved this database in any way.
Start with: Access open with no databases open, resource files
Note: Be careful that you choose the correct file type in the Open dialog or you won't see the files you are looking for.
Import all of the tables and queries in the database gscout-for import.accdb which should be in your resource files .
There are 2 tables
and 14 queries. Some of the queries use tables that you must import separately.
If you have not downloaded the whole set of resource files, you
can find this file and others for the exercises at:
http://www.jegsworks.com/Lessons/resources/databases resources .
Note: The original field names Home Phone
# and Work Phone # were changed
during the export process, dropping the # symbol and instead using a
period, like Home Phone . and Work Phone . That's strange enough, but,
when you imported these fields, the periods were left off. Go figure!
Import the dBase file TRAINING.dbf or the XML file TRAINING.xml from your resource files.
The Import Wizard runs all by itself. If you import the XML file, choose to import both structure and data. Access 2013 and 2016 will not import a DBF file. The XML file version was created from a dBase file which was created from another file format. When exporting in another format, sometimes features get changed. Beware!
You don't need to make any choices! But if you imported the DBF format file, you need to know some quirks about DBF files.
About DBF:
DBF format has often been used for transferring data between different programs over the years. You must be aware of the disastrous effects that these restrictions on names can have!
Exporting into DBF format made several changes from the original. Sometimes these differences make a big difference.
A troop can have several leaders or assistant leaders. An adult can be a leader in more than one troop and can take many different trainings. So you have several One-to-Many relationships. You can create joins but to enforce referential integrity (to get the symbols on the join lines) you must make some changes because some data types don't match.
There are 3 fields named AdultID or ADULTID among the tables. They do not all have compatible data types! This is common with imported data when the primary key values are imported and are numbers. Access will not assign AutoNumber as the type to such fields. Complicating matters, once there is data in a record anywhere, you cannot change a field's data type to AutoNumber! You could delete the ID field and create a new ID field that has AutoNumber data type like you did above, BUT there are already values for AdultID in related tables. What a mess! The work-around is to use Long Integer data type. A field with that data type can be joined to an AutoNumber field.
Examine the records and the design view of each table.
Do you
understand what kind of
information goes in each one?
What kinds of questions was this database designed to answer? What reports could be created? (That's in the next project)
Some queries that you imported to start with use tables that you imported from other sources. You changed the name of the Adult Info table. That broke relationships. Some field names may be different that in the original database! The dBase format, in particular, does not like long names or names with spaces and does like all caps. Eek!
Open each query in Query Design View and create simple joins where needed.
Run the query. If you fail to create the joins, the results will fail or be very odd!
Problem: No tables showing above the grid
Solution: Check the scroll bars, both horizontal and vertical. The tables are just out of sight.
Problem: List of table fields shows only *
The display of the fields is just too short.
Solution: Drag the edge of the table's field list to make it taller.
Problem: One or more tables show but do not show any fields
The named table does not exist in the database. Either it was renamed or the name in the grid no longer matches because of the way it was imported.
Solution: Make notes on what fields are being pulled from the missing tables and what choices are in the design grid for those columns. Add the correct table. Change the field name by selecting from the drop list for that column. Once all corrections have been made, only then can you delete the blank tables. You must then recreate the columns that used data from those tables.
Repair before deleting anything!
If you delete a 'broken' table that show no fields from the Design View, any columns that used fields from that table vanish! You can delete the broken table only after you know you can recreate what the query used from it!
For any field that starts with Expr and a number, like Expr1:[Date] or Expr2:[Adult Info].[Last Name], revise to use an existing field with the name in the brackets [ ] from one of the displayed tables.
Capitalization makes a difference! Event and EVENT are not the same to Access!
Once you have the correct tables in the grid, you may only need to reselect the field name from the drop list in the grid or delete the Expr1: or similar part of the name. Or, you can delete the column and drag the correct field down again yourself.
Problem: Error message says there is syntax error
You may have typed something incorrectly. If you were selecting table name and field name from drop lists instead of typing, Access is just confused.
Solution: Click on OK to close the error message and then on the ESC key to undo your changes to the field. Drag a new copy of the field from the correct table to the grid and delete the old column.
This exercise uses a file from the databases resource files.
You cannot make changes to these files and save them in the same place. Save the changed documents to your Class disk. This keeps the original resource files intact in case you need to start over or another student will be using this same computer.
How to handle a full disk