SlideShare a Scribd company logo
1 of 135
Download to read offline
University Technology Training Center 
Access 2007: 
Advanced Database Development
UNIVERSITY TECHNOLOGY TRAINING CENTER 
Access 2007: 
Advanced Database Development 
© 2009 Regents of the University of Minnesota 
University Technology Training Center 
All Rights Reserved 
uttc.umn.edu 
The University of Minnesota is committed to the policy that all persons shall have equal access to its programs, facilities, and employment without regard to race, 
color, creed, religion, national origin, sex, age, marital status, disability, public assistance status, veteran status, or sexual orientation. 
This publication/material can be made available in alternative formats for people with disabilities. Direct requests to: 
University Technology Training Center 
190 Shepherd Labs 
100 Union Street Southeast 
Minneapolis, MN 55455 
612.625.1300 
uttc@umn.edu 
4 . 3 0 . 0 9
Table of Contents 
LESSON 1 1 
INTRODUCTION 1 
Database Design Vocabulary 
Review 1 
Relationships as of the Access 2007 
Basics Class 3 
Security Options 3 
Design Mode vs. View Mode 
Refresher 4 
LESSON 2 5 
IMPROVING THE EXISTING 
DATABASE 5 
Improvements and Additions 5 
Creating a New Table and Setting 
Properties 6 
Appending Data from tblMemberCD 
to tblCDLoan 8 
LESSON 3 13 
UPDATING RELATIONSHIPS 13 
Updating Relationships 13 
LESSON 4 17 
DATA INTEGRITY 17 
Additional Data Integrity Checks at 
the Table Level 17 
Creating Validation Rules 17 
Exercise 1: Creating Field Level 
Validation Rules 21 
Using Indexes to Prevent Duplicates 23 
Exercise 2: Creating No Duplicates 
Indexes 25 
LESSON 5 27 
EDITING FORMS AND COMBO 
BOXES 27 
Combo Boxes 27 
Exercise 3: Editing Combo Boxes 32 
LESSON 6 35 
ADVANCED FORM CREATION 35 
Handling of CD Loans 35 
Create Query that the Main Form 
Will Be Based Upon 36 
Create the Main Form Showing All 
CDs and Their Owners 37 
Exercise 4: Creating a Subform 39 
Adding a Search Combo Box to the 
Main Form 43 
LESSON 7 47 
IMPORTING DATA INTO AN 
ACCESS DATABASE 47 
Adding a New Member to the Club 47 
Exercise 5: Adding New Genres to 
the Genre Table 55 
Adding new CDs to the Database 57 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER I
Exercise 6: Assigning CDs to the 
New Member 59 
Reusing Action Queries 61 
Exercise 7: Importing Excel Data 
Using an Existing Set of Append 
Queries 61 
LESSON 8 67 
QUERY/REPORT OPTIONS 
FORM 67 
Creating the Query/Report Options 
Form 67 
Exercise 8: Set up the Performer 
Search for the Query/Report Options 
Form 74 
LESSON 9 79 
CREATING REPORTS BASED 
ON DYNAMIC QUERIES 79 
Informing Members of Newly Added 
CDs 79 
LESSON 10 83 
CREATE A NEW DATABASE 
BASED ON AN EXCEL 
SPREADSHEET 83 
Exercise 8: SNORCA Database 83 
APPENDIX A 99 
USING THE OBJECT 
DEPENDENCIES FEATURE 99 
Example: tblMember 100 
Example: frmMemberCD 101 
APPENDIX B 103 
CREATING THE CD 
CONDITION LOOKUP TABLE 103 
APPENDIX C 107 
ACCESS CROSSTAB QUERY 
WIZARDS 107 
APPENDIX D 111 
ADVANCED REPORT 
CREATION 111 
Creating an Overdue CD letter 111 
APPENDIX E 119 
ADDING A PRIMARY 
ADDRESS INDICATOR 119 
APPENDIX F 121 
UPDATING THE 
SWITCHBOARD 121 
Creating the List Maintenance 
Switchboard 122 
APPENDIX G 125 
E-MAIL FORMS 125 
I I UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
Introduction 
1 
Lesson 1 
Lesson In this class, we will expand on the skills used in the Basics class by making 
improvements to the CD Club database. We will pick up right where we left 
off, with a workable but simple database for tracking the loaning of CDs 
between members of the CD Club. In making changes to this database we 
will learn what effects those changes have to existing data, tables, forms, 
queries, and reports. 
Database Design Vocabulary Review 
Databases 
ƒ Field: One piece of information you want to track in your database 
o Examples: Name, Birth Date, CD Title, etc. 
ƒ Record: A group of fields containing data about one particular 
person, event, item, etc. 
o Examples: CD Title—Artist—Genre—Release Year 
ƒ Table: A group of records 
Best Practice 
When you expect multiple values or repeating data in a table, you 
should consider splitting the table into two or more related tables. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 1
LESSON 1: 
I NTRODUCTION 
Relationships 
Types of Relationships 
ƒ One-to-Many: The most common type. For every record in Table A, 
there are multiple records in Table B. 
o Example: One Member may have many Addresses (work, 
home, cabin, etc.) 
ƒ Many-to-Many: For every record in Table A, there are multiple 
records in Table B, and vice versa. In this case, a third table—called a 
Join Table—needs to be created that will contain only unique values. 
o Example: One Member may have many CDs, and the same 
CD may be owned by many Members 
Best Practice 
The Join Table name should be a combination of the two many-to-many 
tables (e.g., tblMemberCD). 
ƒ One-to-One: The rarest type, it is used for security and organization 
(i.e., avoiding empty fields that only apply to some records in the 
table) 
ƒ Primary Key: Auto-numbered, unique ID for internal database use 
and in matching records between related tables 
ƒ Foreign Key: A number-type field in a related table pointing back to 
the Primary Key in another table 
Best Practice 
The Primary Key should be the table name plus “ID” (e.g., 
MemberID) and should be the same name in a related table where it 
is used as a Foreign Key. (There are exceptions. In this course, the 
Foreign Keys LoanedToID and MemberID in tblMemberCD table 
both go back to the Primary Key MemberID in tblMember.) 
The Primary Key for a Join Table can be the Join Table name or the 
first initial of each table name followed by ID (e.g., MemberCDID). 
2 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 1: 
I NTRODUCTION 
Relationships as of the Access 2007 Basics Class 
Security Options 
New in Access 2007 
This small menu bar replaces the security popup window in Access 2003. In 
mid-March 2008 an Office 2007 service pack was released and the warnings 
have gone away completely. If you don’t have the service pack installed, you 
will want to click on Options and choose the “Enable this Content” radio 
button if you have any Macros, Action Queries, or VBA code in the database. 
Otherwise, you can chooose the default of “Protect me from this content.” 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 3
LESSON 1: 
I NTRODUCTION 
Design Mode vs. View Mode Refresher 
For all objects we work with in this class, we will be switching back and 
forth between Design View of the object and the end user view or result 
(data sheet, form, query results, or report results). The method of changing 
the view is identical. 
From the Home tab on the ribbon, choose the first icon on the left: 
ƒ To switch to data sheet, form, or results 
ƒ To switch back to Design View 
4 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
Improving the Existing Database 
Improvements and Additions 
2 
Lesson 2 
Lesson What Improvements or Additions Can We Make to This 
Database? 
The refine and test phase of database development is an ongoing process. As 
the database is used, things will come up that need to be corrected or 
improved upon, processes or requirements may change, or you may have 
learned a new Access skill you wish to put to use. Working with a database 
that already has data entered or is in constant use adds another level of 
difficulty to the process. We will explore the features in Access 2007 that 
help make this process easier. 
Problem: The database currently does not retain any history of the 
CD loan; it only tracks if a CD is on loan at the present 
time. 
Solution: Create a separate table to record every time a CD is loaned 
out. 
Problem: Currently nothing stops you from entering duplicate data. 
Solution: Add indexes where needed to prevent duplicates 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 5
LESSON 2: 
IMPR O V I N G T H E E X I S T I N G DATABAS E 
Other Additions/Changes We Could Make: 
ƒ Additional field properties to prevent incorrect data being entered 
through the forms 
ƒ A form for running queries/reports with dynamic criteria 
ƒ Importing a new member’s CDs to save data entry time 
Creating a New Table and Setting Properties 
Start by creating the new table, in Design View, needed for the additional 
information. Set field properties for size, format, input masks, and default 
values where appropriate. 
Best Practice 
Set all the field properties and options at the table level so they 
propagate through the forms for data entry 
CD Loan History 
This table will store every loan transaction for historical tracking. The 
MemberID field here corresponds to the borrower of the CD. We will not be 
adding input masks to the DateOut or DateIn fields so we can take 
advantage of the new calendar control option. 
Figure 1: CDLoan table in Design View 
1. Open the file CDClubDay1.accdb 
2. Create the fields as shown in Figure 1, above 
3. Add the Date() formula into the Default Value of DateCreated 
6 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 2: 
IMPR O V I N G T H E E X I S T I N G DATABAS E 
Now we have a new table to store all of the CD loan transaction history. The 
Member CD table has existing information regarding current loans. 
At this point, a decision has to be made about the existing loan information: 
ƒ Start from scratch 
ƒ Populate the existing loans into the new table manually 
ƒ Populate the existing loans into the new table programmatically 
In this case, we wouldn’t want to lose track of any CDs currently on loan to 
other members. Reentering the data is time consuming and can lead to data 
entry errors, so we will opt to import the data into the new table 
programmatically by using a type of query called an action query, 
specifically an Append type of action query. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 7
LESSON 2: 
IMPR O V I N G T H E E X I S T I N G DATABAS E 
Appending Data from tblMemberCD to tblCDLoan 
1. From the Create Tab choose Query Design 
2. Add tblMemberCD and close the Show Table dialog box 
3. Add the following fields to the grid: 
• MemberCDID 
• LoanedToID 
• DateOut 
• DateCreated 
4. Preview the query using the View Toggle 
Note that all CDs are listed—even ones that have never been loaned out. We 
only need to pull information for those CDs that are currently loaned out. 
8 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 2: 
IMPR O V I N G T H E E X I S T I N G DATABAS E 
Setting Criteria for the Query 
1. Return to Design View using the View Toggle 
2. Add Is Not Null to the Criteria under the DateOut field 
3. Preview the results using the View toggle 
Now we have only the records we need to populate the CD Loan table. You 
should have 11 records showing. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 9
LESSON 2: 
IMPR O V I N G T H E E X I S T I N G DATABAS E 
Setting Up the Append Query 
1. Return to Design View 
2. On the Design tab, under Query Type, choose Append 
3. In the Append dialog box, choose tblCDLoan from the dropdown 
menu and click OK 
A new line will be added into the query grid—Append To. If Access finds 
matching fields between the query and the table being appended to, it will 
automatically populate this row. If the fields are named differently you would 
have to manually choose the matching field from the dropdown list. 
Note that LoanedToID does not match up with a field name in the Append To 
Line. That is because there is no field named LoanedToID in the CD Loan table. 
We called it MemberID so we have to choose that field manually. 
10 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 2: 
IMPR O V I N G T H E E X I S T I N G DATABAS E 
4. Click in the Append To row under LoanedToID and use the 
dropdown button to select the MemberID field. 
Previewing the query results at this point just shows the selected records as 
before they were changed to an Append query. Since this is an action query we 
need to run the query to produce results. 
5. Click the Run button to run the query. It’s next to the View Toggle. 
6. Click Yes to confirm the Appending of the 11 records 
7. Close and Save the query as qryAppendCDLoan 
FYI 
All action queries have different icons to distinguish them from 
other action queries…and most importantly from the Select queries. 
The Append query has the icon and will run if double clicked; it 
won’t just open a results set. This may have unwanted consequences 
to your data. Access does give you a warning before executing any 
action query. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 11
LESSON 2: 
IMPR O V I N G T H E E X I S T I N G DATABAS E 
Verify Results and Remove Old Fields 
1. View the contents of tblCDLoan to verify the records were 
appended. 
2. Open tblMemberCD in design view 
3. Select and Delete the LoanedToID and DateOut fields 
4. Click Yes to confirm deletion of the selected fields 
5. Click Yes to confirm deletion of the Indexes along with the removal 
of the LoanedToID field 
6. Close the table and Save the design changes to tblMemberCD 
7. Delete the one-time query qryAppendCDLoan 
12 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
Updating Relationships 
3 
Lesson 3 
Lesson Now that we have updated all the tables and fields, we need to update the 
relationships as well. All the new tables need to be added to the 
relationships window and their primary and foreign keys linked 
accordingly. As always, set Referential Integrity to prevent orphan records 
or accidental deletion of records. 
Updating Relationships 
1. On the Database Tools Tab click on Relationships 
2. Right-click in the diagram and choose Show Table 
3. Add tblCDLoan 
4. Link tblCDLoan to tblMemberCD by the matching Primary 
Key/Foreign Key field 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 13
LESSON 3: 
UPDAT I N G RE LAT ION S H IPS 
5. Check Enforce Referential Integrity 
6. Before we couldn’t link from LoanedToID to MemberID because we 
already had a link from MemberID to MemberID 
Now that we have moved the Loaned To Member’s ID to a new table 
(tblCDLoan) we can now set a relationship and enforce referential 
integrity. 
7. Link the MemberID in tblCDLoan to the MemberID in tblMember 
8. Set Referential Integrity 
14 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 3: 
UPDAT I N G RELAT ION S H IPS 
Updated Relationships 
9. Close and Save the relationship diagram 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 15
Data Integrity 
4 
Lesson 4 
Lesson Additional Data Integrity Checks at the Table Level 
The information we get out of a database is only as good as the information 
that goes in. Database developers should do all they can to ensure accurate 
and consistent data is entered. We have already explored a few ways to limit 
what can be entered into a field. Here we will discuss a few additional steps 
you can take. 
Creating Validation Rules 
All data entered into the field must meet the criteria given. A descriptive 
message can be displayed when data violates the criteria. If you create a 
validation rule after data has been entered into that field, Access will ask 
you if you want to check existing data against the validation rule. 
LastName and FirstName fields cannot be left blank in 
tblMember 
Changing the Required setting on the General tab from No to Yes would 
accomplish this task, but the violation message displayed by Access when 
this rule is violated is more user friendly than it used to be: 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 17
LESSON 4: 
DATA INT E G R I TY 
Or you can use the validation rule and text option to create a custom 
message: 
1. In Design View of tblMember choose the FirstName field 
2. In the General tab of the Field Properties area at the bottom of the 
table design screen, locate the Validation Rule and Validation Text 
fields 
• In the Validation Rule field type Is Not Null 
• In the Validation Text field type First name is required 
3. Repeat the process for LastName 
4. Close and Save the table design changes. You will get a message to test 
the data against the new validation rules. Click Yes 
5. Open frmMember and enter a new Record leaving the First Name 
and Last Name fields blank (just fill in the Birthday field) and test the 
error messages. 
18 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 4: 
DATA INT E G R I TY 
DateIn in the CD Loan table cannot occur before DateOut 
1. In Design View of tblCDLoan choose the DateIn field 
2. In the General tab Validation Rule type the following: 
The above Validation Rule looks logical—and it would be accepted initially— 
until you save the design changes and run the validation check against existing 
data. At that point you will get the following error message: 
You cannot reference another field in a validation rule. Instead, we will create a 
Table level validation rule. 
3. Delete the text from the Validation Rule 
4. Right-click anywhere in the empty grid area of the table design 
5. From the pop-up menu, choose Properties 
From the Table Properties dialog box, you will see a different set of Validation 
Rule and Validation Text fields. These rules are applied and must be met before 
the record can be saved. Now we can reference fields in the table. (You can 
check values of fields within the same record but not between two different 
records or other tables.) 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 19
LESSON 4: 
DATA INT E G R I TY 
6. In the Validation Rule field type [DateIn]>=[DateOut] (note: brackets 
are required) 
7. In the Validation Text field type Date checked in cannot be 
prior to date checked out 
• This is what the message will look like on the form we create later 
in class: 
8. Close and save the table design changes. Click Ok on the validation 
error message. 
20 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 4: 
DATA INT E G R I TY 
Exercise 1: Creating Field Level Validation Rules 
CD Title in tblCD Cannot Be Left Blank 
1. Open tblCD in design view 
2. In the Title field’s Validation Rule type is not null 
3. In the Validation Text type CD Title is Required 
CDValue in CD Table Must Be a Positive Dollar Amount 
Greater Than Zero 
1. In the CDValue field’s Validation Rule field type >0 and is not null 
2. In the Validation Text field type Value greater than 0 is 
required 
3. Close and save the Table design changes 
4. Test both the title and value validation rules using the CD form 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 21
LESSON 4: 
DATA INT E G R I TY 
DateOut and DateIn Fields in the CD Loan Table Cannot Be In 
The Future 
1. Open tblCDLoan in design view 
2. In the Validation Rule field of DateOut type <=Date() 
3. In the Validation Text field type Date Out cannot be in the 
future 
4. Repeat for DateIn field 
No form has been created to test this yet. It will be tested at a later time. 
5. Close and save the table design changes, click OK on the validation 
error message. 
End of Exercise 
22 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 4: 
DATA INT E G R I TY 
Using Indexes to Prevent Duplicates 
Indexes are used by a database to sort and find records. You don’t want to 
index every field; this would create excess overhead and bog down the 
database. Only index fields you would most often search by. Primary Keys 
are automatically indexed and are unique, but the actual data is not. Access 
also gives you the option to require unique values as part of an index. There 
are many fields for which you would want to ensure unique values 
(especially fields in lookup tables). 
In the field properties area of table design there is an Indexed line. The 
options given in the dropdown are: 
ƒ No This is the default 
ƒ Yes (Duplicates OK) 
ƒ Yes (No Duplicates) 
To ensure unique values in the following fields, set the Indexed option to 
Yes (No Duplicates). 
Creating an Index over a Single Field 
1. Performer in lookup table tblPerformer 
2. Genre in lookup table tblGenre 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 23
LESSON 4: 
DATA INT E G R I TY 
Creating an Index over Multiple Fields 
You can also create an index over multiple fields. We need to do this in the 
Member table to prevent a person from being entered into the database 
twice. We will use a combination of First and Last Names. Middle name is 
often left blank so John Smith and John A Smith would be allowed as 
separate records. If we use Birthday in place of Middle name we will have 
better duplicate prevention. 
1. Open tblMember in Design View 
2. Click on the Indexes button in the Design Tab. 
The Indexes dialog box will open with PrimaryKey and MemberStatusID 
already showing 
3. Type MemberName in the next empty cell in the Index Name 
column 
4. Select the LastName field from the dropdown under Field Name 
5. Change Unique to Yes in the lower Index Properties section 
6. On the next line, leave the index name blank (telling Access this is 
part of the index above) and select FirstName 
24 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 4: 
DATA INT E G R I TY 
7. On the next line repeat for Birthday 
8. Close the Indexes screen 
9. Close and Save tblMember 
Exercise 2: Creating No Duplicates Indexes 
Index on Single Fields 
1. MemberStatus in lookup table tblMemberStatus 
2. AddressType in lookup table tblAddressType 
Index on Multiple Fields 
For the CD records, we could just put an index on the Title field, but that 
could cause issues with 2 Performers having the same title. Instead we will 
do a combination of Title, Performer, and Year Released as our duplicate 
prevention. 
1. Open tblCD in Design View 
2. Click on the Indexes button in the Design Tab 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 25
LESSON 4: 
DATA INT E G R I TY 
The Indexes dialog box will open with PrimaryKey, PerformerID, and GenreID 
already showing 
3. Type PerfTitleYear in the next empty cell in the Index Name column 
4. Select the PerformerID field from the dropdown under Field Name 
5. Change Unique to Yes in the lower Index Properties section 
6. On the next line, leave the index name blank (telling Access this is 
part of the index above) and select Title 
7. On the next line repeat for YearReleased 
8. Close the index screen 
9. Close and Save the Table 
End of Exercise 
26 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
Editing Forms and Combo Boxes 
5 
Lesson 5 
Lesson Combo Boxes 
You may have noticed that combo boxes—even though they may have many 
fields displayed when you click on the dropdown—only display the first 
field once you make a selection. Sometimes it would be helpful to see more 
information in the combo box. You can accomplish this by editing the combo 
box Row Source. (You can’t go back to the wizard after a combo box is 
created.) Be sure you still have the primary key field as the first field in the 
combo box or your selection won’t be saved correctly into the table. 
Editing Combo Boxes 
Show Title and Performer on Member CD Form Combo Box 
1. Open frmMemberCD in Design View 
Oops! Notice the green triangles in the upper left corners of the Loaned To and 
Date Out fields. These fields are no longer valid because we removed them from 
the table tblMemberCD (which this form is based on) and are now in 
tblCDLoan. 
2. Delete the two invalid fields from the subform 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 27
LESSON 5: 
E D I T I N G FORMS AN D COMB O BOXES 
3. Expand the CD field to fill the width of the form 
4. Now we can edit the combo box. Right-click on the field and choose 
properties 
5. In the Data Tab → Row Source, click on the (ellipses) button to 
pull up the query that is created behind the combo box 
Note: 
This query only exists within the context of the form; there is no 
saved query object in the objects window. If it were a saved query, 
you would see the query name (qryXXXX) rather than the SQL 
query statement (i.e., SELECT * FROM tbl….) 
6. Use the Show Table option to add tblPerformer to the query design 
7. Concatenate the Performer name to the Title field: Change the 
existing Title field to CD: [Title] & “ by “ & [performer] 
Note: the second [Title] field is used for sorting, this came from the query 
wizard and shows up this way in 2007 only. 
8. Close the query and Save your changes 
28 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 5: 
E D I T I N G FORMS AN D COMB O BOXES 
Important Notes! 
Don’t click on Save to close the query or it will prompt you to create 
a query object outside of the form 
Be careful not to change the order or amount of fields or remove the 
CDID from the query. 
Edit the Format of the Combo Box and the Form 
1. Widen the column that contains the new combined field 
• Switch to the Format tab of the Combo Box 
• In the Column Width line, there are three numbers. 
○ The first is 0 because it is the hidden Primary Key field 
○ The second is the newly concatenated CD title and performer 
column. Change the value from 1.8438 to 4 
○ Change the list width to Auto 
2. Close the properties window 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 29
LESSON 5: 
E D I T I N G FORMS AN D COMB O BOXES 
3. Switch to Form view to see the changes to the combo box content 
Instead of having the CD label at the left of the field, repeated for each field, we 
can move it to the top of the subform easily using one of the new Arrange 
options 
4. Switch back to design view 
5. Select the CD combo box 
6. On the Arrange tab choose Tabular 
The label will move to the Header section of the form: 
30 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 5: 
E D I T I N G FORMS AN D COMB O BOXES 
7. Switch to form view to see the change 
8. Close and Save the form 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 31
LESSON 5: 
E D I T I N G FORMS AN D COMB O BOXES 
Exercise 3: Editing Combo Boxes 
Show Title and Performer on the CD Form’s combo box 
1. Open frmCD in Design View 
2. Right-click on the Find CD Combo box field and choose Properties 
3. Click on the Data tab 
4. Click once in the Row Source line 
5. Click on the ellipses button at the end of the row 
6. Add the Performer table to the query 
7. Concatenate the Performer field at the end of the Title to look like 
this: CD: [Title] & " by " & [performer] 
8. Close and Save the changes to the query 
9. In the Properties window for the combo box, adjust the width of the 
combo box using the Format Tab to allow for the combined field. 
• Change the Column Width (the second value) from 3.3334 to 4 
• Change the List Width to Auto 
32 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 5: 
E D I T I N G FORMS AN D COMB O BOXES 
10.View and test your changes on the form (drop down the combo box) 
11.Close the form and Save your design changes 
End of Exercise 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 33
Advanced Form Creation 
6 
Lesson 6 
Lesson Handling of CD Loans 
A new loan table was created in order to keep the history of all CD loan 
transactions, rather than just the current status of the CDs. Now, a new form 
needs to be created to handle these transactions. In class, we will look at this 
form in the simplest approach. See the appendix for separate forms for 
processing the transactions (check out, check in) and seeing the entire loan 
history for a CD. 
Completed CD Loan form 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 35
LESSON 6: 
ADVANC E D FORM CREAT ION 
Create Query that the Main Form Will Be Based Upon 
For the main part of this form we need to pull in the information pertaining 
to the individual CDs, as well as who owns that particular copy, and display 
it in a read-only fashion. We already have a query—created in the Access 
Basics class—that pulls this information together. We will make a copy of 
that query to use on this form. 
Copy a similar Query and Edit in Design View 
1. In the Queries objects, find the query called qryCDListWithOwners 
2. Right-click on this query and copy 
3. Click in the queries area and choose paste 
4. Name the copy: qryCDLoanMain 
5. Right-click on the query and choose Design View 
Note that we have the following fields pulled into the query grid: 
o Title 
o YearReleased 
o Genre 
o Performer 
o A temporary concatenated field: Owner: LastName &”, “& 
FirstName 
Additionally we need to have the MemberCDID in the query grid (as it is the 
primary key/foreign key link between the CDs (tblMemberCD) and the Loans 
(tblCDLoan), which will be displayed in the subform). 
36 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 6: 
ADVANC E D FORM CREAT ION 
6. Drag the MemberCDID from tblMemberCD and place it in the FIRST 
column of the query grid (in front of the Title field) 
Note: 
We don’t need to pull in the loan information at this point; it will be 
in the subform. 
7. Add a sort to this query by choosing Ascending in the sort row in the 
Title Column 
8. Close and Save the query design changes 
Create the Main Form Showing All CDs and Their 
Owners 
1. With the qryCDLoanMain selected, click on the Create tab and then 
click on Form 
2. Switch to design view 
3. Click outside of the grouped fields to deselect them 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 37
LESSON 6: 
ADVANC E D FORM CREAT ION 
4. Edit the header Label to read CD Loans 
5. Delete the MemberCDID field 
6. Put a space in the YearReleased label 
7. Edit field Properties 
• Select all of the fields in the detail section at once (not the labels) 
• Right-click on the group and choose Properties 
• On the Data tab, set Enable to No and Locked to Yes (to disable 
both selecting and editing of these fields) 
8. Edit form Properties 
• Right-click the black box in the upper left corner of the form and 
choose Properties 
• Click on the Format tab 
• Change the Record Selectors option to No 
○ Users won’t be editing or deleting any records in the main 
form. 
9. Close the Properties window 
10.Switch to Form view 
11.Close and save the form as frmCDLoan 
38 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 6: 
ADVANC E D FORM CREAT ION 
Exercise 4: Creating a Subform 
In this exercise, you will create the subform for the Loan transactions for 
each CD in the main form and then link it to the main form. 
Creating the Subform 
1. Select tblCDLoan from the table list 
2. From the Create tab choose Multiple Items 
3. Switch to design view and deselect the group 
4. Change the Label in the header to read Loan History 
5. Delete the unneeded key fields: CDLoanID, MemberCDID, and 
MemberID (memberID will later be replaced with a combo box) 
6. Delete the Date Created field (we will end up with too many date fields 
and it will most often be the same as the Date Out) 
7. Create a combo box for Loaned to using the Combo Box wizard 
• Select the Combo Box from the Controls section of the design tab 
and drop it to the right of the other fields in the detail section 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 39
LESSON 6: 
ADVANC E D FORM CREAT ION 
• Choose the I want the combo box to look up the values in a table 
or query option (first one) → Next 
• Choose tblMember 
• Select the following fields: 
○ MemberID 
○ LastName 
○ FirstName 
• Click Next 
• Sort by LastName, then FirstName → Next 
• Adjust fields as needed → Next 
• Choose to store that value in the field: MemberID → Next 
• Name the combo box Loaned To → Finish 
• Widen the field 
8. Select the Combo box and move it to the left side of the detail section. 
As you move it over, you will see an orange bar between the other fields, if 
you drop it on that orange bar it will go into the grouping with the rest of the 
fields and the title will automatically move to the header section. 
9. Add a Date Due calculated field to the subform to display the date 
out plus the 10 day loan period. 
• Add a text box from the Design Tab 
40 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 6: 
ADVANC E D FORM CREAT ION 
• Right-click on the field and choose Properties 
• On the Data tab, click in the Control Source field and click on the 
Expression Builder ellipses button 
• Starting at the left side, Choose Functions → Built-In Functions → 
Date/Time → DateAdd 
DateAdd («interval», «number», «date») will appear as your formula. The 
interval is the part of the date you want to add to (‘d’ for day in our case), 
number is the number to add to the interval (10 in our case), and date is the 
date field we are adding to for the calculation (dateout). 
The formula should look like this: DateAdd(‘d’,10,[dateout]), remove 
anything else that may show up in this window. 
• Click OK to close the expression builder 
• Edit the label to read Date Due 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 41
LESSON 6: 
ADVANC E D FORM CREAT ION 
10.Move the field to the end of the other fields, making sure you drop it 
on the orange bar to make it part of the group 
11.Close and Save the form as subfrmCDLoan 
Note: No data entry should be done directly into a sub form, only 
once it is linked to the parent form. 
Link the Subform and Main form 
1. Open the main form frmCDLoan in Design View and insert the 
subform 
• From the Controls section of the Design Tab select the 
(Subform) icon 
• Click below the Owner field where you want the subform to be 
placed 
• Using the Subform wizard choose subfrmCDLoan from the list of 
exisiting forms. 
• Choose to link the forms by the common key field MemberCDID 
• Click Finish 
2. Delete the label that says subfrmCDLoan 
3. Make the subform taller so more records can be displayed 
4. Switch to form view to see the results 
5. Loan a CD out to someone and verify the Date Due calculation is 
working 
6. Close and Save your design changes 
42 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 6: 
ADVANC E D FORM CREAT ION 
frmCDLoans with subform 
Adding a Search Combo Box to the Main Form 
1. Open frmCDLoan in design view 
2. Below the “CD Loans” label in the header area, create a Combo box to 
lookup the CDs 
• Add a combo box to the header from the Toolbox 
• Choose the third option, Find a record on my form… 
• Choose all fields 
• Click Next 
Because we based the form on a query that pulls in multiple tables, it does not 
automatically hide the key field (MemberCDID), so we must manually shrink 
that field so it does not show. The Title field should also be expanded. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 43
LESSON 6: 
ADVANC E D FORM CREAT ION 
Before: 
After: 
1. Click Next 
2. Name the Combo box Find CD 
3. Click Finish 
4. Change the text of the “Find CD” label to bold 
5. Widen the unbound combo box to the width of the form 
44 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 6: 
ADVANC E D FORM CREAT ION 
6. Switch to form view and test the drop down 
7. Close and Save the form 
End of Exercise 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 45
Importing Data into an Access 
Database 
7 
Lesson 7 
Lesson Adding a New Member to the Club 
Ideally, you want to automate as much as possible in the database to save 
time and typing. Adding a new member’s list of CDs is a good place to use 
automation. Assume you give the new member an Excel template for 
him/her to enter all of his/her CDs. This includes value and year released. 
The new member can enter any appropriate values into Performer and 
Genre. We will import the data into a temp table and use action queries to 
check the data for new values and place it in the appropriate relational 
tables. The action queries created in this exercise can be used over and over. 
Use CDClubDay2 
Add the new Member 
1. Open frmMember 
2. Go to a new record and add Peppermint Patty 
○ Birthday : 3/17/1976 
○ Home Address: 123 Sir Charles Lane, St Paul, 55107 
• Take note of the MemberID assigned to her 
3. Close the form 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 47
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
Import from Excel Spreadsheet template 
1. On the External Data tab in the Import section choose Excel 
2. Browse to Desktop → Access 2007 Advanced → Class Files folder 
3. Select Peppermint Pattys Music Collection Excel file 
4. Select import the source data into a new table in the current 
database 
5. Click OK and the Import Spreadsheet wizard will appear 
48 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
6. Click Next 
The first row contains column headings and should be checked, as we have the 
Field names in the first line of our Excel template. 
7. Click Next 
No additional field formatting needs to be done (using this screen you could 
skip fields, change data types, rename fields or set indexes) 
8. Click Next 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 49
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
9. Since this is just a temporary table, choose No primary key and click 
Next 
10.Save the table as tblNewCDList (keep the name generic as it will be 
reused for all imports of CDs into the club) 
11.Click Finish → Close. We don’t need to save the import steps; they will be 
different next time. 
Note that there are 25 CDs to be added for this member. 
At this point you can start to divvy the fields up into their respective tables. 
First we need to determine if there are new Performers or Genres that need to 
be added to the lookup tables. 
Create a query to match up the Performers from the existing 
Performer Table 
1. Right-click on tblPerformer 
2. Choose Copy then Paste to make a backup copy of the table to be 
appended to 
3. From the Create tab choose Query Design 
4. Add tblNewCDList 
5. Add tblPerformer 
50 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
6. Link by the performer fields (to match up the performer names in the 
2 tables) 
7. Pull the Title and Performer fields from tblNewCDList 
8. Preview the query to see the matches found 
Of the 25 CDs only 3 matching performers are found in our database, the rest 
will need to be added. 
Determine Missing Performers and add them to tblPerformer 
1. Return to the query design 
2. Right-click on the relationship line between the performer fields and 
choose Join Type 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 51
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
By default, a relationship between two tables ONLY brings back records where 
a match is found both tables. We want to see where there isn’t a match in one of 
the tables (tblPerformer). We need to choose option 2 or 3, which one you need 
will vary. A way to remember which to choose is the first table in the statement 
is the one you know has the values in it (tblNewCDList) and the second table 
in the statement is the one where values may be missing (tblPerformer) 
3. Choose option 2: Include all records from tblNewCDList and only 
those records from tblPerformer where the joined fields are equal 
4. Click OK 
5. Add the Performer field from tblPerformer to the grid 
6. Preview the results 
All 25 CDs are showing again. Those with a blank Performer field are the 
Performers that need to be added. 
52 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
7. Return to Design View and remove the Title field (it was only there 
for reference, we only want to look at the performers now) 
8. Add Is Null to the criteria under tblPerformer.Performer (to see only 
the missing performer matches) 
View the query results again. We now see only the missing performer records, 
but there are duplicates 
Grouping the Performer names to get a unique list 
1. Return to design view 
2. From the Show/Hide section of the Design Tab, click Totals (to group 
by Performer and not show duplicates) 
3. Change Group By to Where under tblPerformer.Performer (the one 
we need just for criteria purposes) 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 53
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
4. Uncheck Show under tblPerformer.Performer 
5. View the query 
Now you have the list of the 11 missing performers to add. 
6. From the Design Tab choose the Append query type 
7. Choose tblPerformer from the drop down 
54 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
8. Delete Performer in the Append To line under 
tblPerformer.Performer Only the Performer name from the New CD list 
can be used in the Append operation. The second Performer field is there only 
for the criteria of locating the non matching records. 
Running the Query 
1. Run the query using the Exclamation button 
2. Click yes to Confirm appending 11 rows 
3. Save the query as qryAppendNewPerformers 
4. Verify the additions of the 11 new performers using the Performer 
form 
Exercise 5: Adding New Genres to the Genre Table 
Match Up Genres to Find Missing Values 
1. Copy and Paste tblGenre and to make a backup 
2. Create a new Query Design 
3. Add tblNewCDList 
4. Add tblGenre 
5. Link on the Genre fields 
6. Pull Genre from both tables into the query grid 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 55
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
7. Change the join type so all records are pulled from tblNewCDList 
and only those with matching records in tblGenre 
8. Type Is Null in the criteria under the Genre field from tblGenre and 
uncheck Show 
9. From the Show/Hide section choose Totals 
10.Change the Total option under tblGenre.Genre from Group By to 
Where 
11.Preview the query 
You should have just the 3 missing genres 
Finish and Run the Append Query 
1. Return to Design View and change the query to an Append Query 
type 
2. Append to tblGenre 
3. Remove Genre from the append line for the Genre field from 
tblGenre 
56 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
4. Run the Query using the ! 
5. Confirm the Appending of three records 
6. Save the query as qryAppendNewGenres 
7. Verify the three were added using the Genre form 
End of Exercise 
Adding new CDs to the Database 
Now we will create a query to match up the Performer and Genre fields to 
replace with the corresponding IDs (foreign keys), which are the values 
actually stored in the CD table. 
1. Right click on tblCD and choose copy, then paste (to make a backup) 
2. Create a new Query Design 
3. Show tblNewCDList, tblGenre, tblPerformer 
4. Join tables by the Performer and Genre value fields as before (so we 
can eventually find the corresponding Key values that are assigned to 
them) 
5. From tblNewCDList, add the Title field 
6. From tblPerformer, add the PerformerID field 
7. From tblGenre, add the GenreID field 
8. From tblNewCDList, add the Value and Year Released fields 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 57
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
9. Preview and verify all 25 CDs are listed 
The query results are now showing keys for Performer and Genre so the fields 
now match up to the tblCD design 
Setting Up the Append Query 
1. Change the query to an Append query 
2. Append to tblCD 
Notice that Year Released and value fields do not have a corresponding field in 
the Append To Line. Access will automatically find matching fields if they are 
spelled the same. In this case Year Released from our temp table and formerly 
the Excel template has a space between the words and Value had to be called 
CD value to avoid using an access key word. We need to manually select the 
correct field for each to append to or these fields will be skipped. 
3. In the Append To line under Year Released select the appropriate 
field from the table we choose to append to, YearReleased 
4. In the Append To line undervalue select the appropriate field from 
the table we choose to append to, CDValue 
58 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
5. Run the query 
6. Click yes to confirm appending 25 rows 
7. Save the query as qryAppendNewCDs 
8. Verify the CDs were added correctly using the CD Form 
Exercise 6: Assigning CDs to the New Member 
Create a Query to add the newly created CDIDs to the members list of 
owned CDs stored in tblMemberCD 
1. Copy and paste tblMemberCD to create a backup copy 
2. Create a New Query using Query Design 
3. Add tblNewCDList and tblCD 
4. Join by the Title field and the Year Released field (in case there 
would be the same title by a performer from different years) 
5. Select CDID and Title fields from tblCD 
6. Preview the query and verify the correct 25 CDs are returned in the 
query results and return to Design View 
Autofill the MemberID and Append 
1. Remove the Title Field 
2. We have 2 options for getting the Member ID assigned to this list of 
CD’s 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 59
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
• Option 1: AutoFill the newly created MemberID for each CD 
record. In the next available column, create a new field MemberID: 
xx (where xx = the ID you noted when adding Peppermint Patty 
to the Member form) 
Or 
• Option 2: Ask the person running the query what ID to use. In the 
next available column, create a new field MemberID: [Please 
Enter the MemberID]. 
This option is preferred as it will prompt you to have the correct 
MemberID and save you from forgetting to change it before you 
run it for the next person. 
3. Change the query to an Append query 
4. Append to tblMemberCD 
5. Run the query 
6. Fill in Peppermint Patty’s MemberID 
7. Click Yes to confirm appending 25 records 
8. Save the query as qryAppendNewMemberCDs 
9. Verify results through the Member CD form 
60 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
10. Delete the “copy of…” versions of tables: Genre, Performer, CD, 
and MemberCD 
End of Exercise 6 
Reusing Action Queries 
These action queries can be used each time a new member joins, or in this 
case, an existing member has a large list of new CDs to add. Verify each step 
as you go. The only thing that needs to be changed in the queries is the 
MemberID in the last query. 
Exercise 7: Importing Excel Data Using an Existing 
Set of Append Queries 
Note: The search field at the bottom of the form is the quickest 
way to find a record. If a field is locked and disabled that search 
will not be able to look in that field. To correct that, you would 
have to go to the properties of the field and set Enabled to Yes 
(leaving locked as No) 
1. What is the MemberID for Mickey Mouse ? _____ 
2. How many CDs does Mickey currently have in the club? _____ 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 61
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
3. Delete the records in tblNewCDList in datasheet view 
• Click in the box on the upper left corner of the table to do a Select 
All, then press Delete 
• Close the table before going on to the next step 
4. Import the MickeysNewCDs.xls file from the class files folder into 
tblNewCDList 
• External Data Tab, Import section , choose Excel 
• Browse to MickeysNewCDs 
• This time choose the second radio button, Append a copy of the 
records to the table: 
• Choose tblNewCDList from the dropdown 
• Click ok 
5. In the Import Spreadsheet Wizard click Next → Next → Finish 
6. Close the import. Do not save the import process. 
Adding the New Performers 
1. View the tblNewCDList and note the record count._____ 
62 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
2. Make backup copies of tblPerfomer, tblGenre, tblCD, and 
tblMemberCD 
3. Open qryAppendNewPerformers in Design View. Don’t double click 
and run it yet. 
4. Preview the results and see which Performers will be added. You 
should have 13. 
5. Switch back to Design view and Run the action query 
Adding the New Genres 
1. Open qryAppendNewGenres in Design View (don’t double click and 
run it yet) 
2. Preview the results and see which Genre will be added. 
The 1 new genre 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 63
LESSON 7: 
IMPO R T I N G DATA INTO AN ACCESS DATABASE 
3. Run the action query 
Adding the New CDs 
1. Open qryAppendNewCDs in Design View. Don’t double click and 
run it yet. 
2. Preview the results and see which CDs will be added. You should have 
30. 
3. Run the action query. You may get an error if some CDs already exist, 
click yes to continue and not add the duplicates. 
Assigning the New CDs to the Member 
1. Open qryAppendNewMemberCDs in Design View (don’t double 
click and run it yet) 
2. Preview the results and enter Mickeys MemberID. Verify the correct 
number of CDs are being assigned ownership to Mickey. He should 
still have 30. 
3. Run the action query 
4. Verify through the member CD form that all the new CDs were added 
to Mickey’s existing list. His existing count of CDs plus the count of 
newly added CDs. 
Clean up the tables 
1. Delete the backup copies of tblGenre, tblPerformer, tblCd, and 
tblMemberCD 
2. Delete the data (only the data, not the table) from tblNewCDList so 
it is ready for the next use 
64 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 7: 
IMPORT ING DATA INTO AN ACCESS DATABASE 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 65
Query/Report Options Form 
8 
Lesson 8 
Lesson Rather than having to edit the criteria of a query every time you want to run 
it, you can create a user-friendly form to select or enter the criteria and run 
the query or report based on that selection. Using dropdowns on this form 
not only makes it easier, but it ensures that accurately spelled and existing 
values are used in the criteria. The dropdowns pull from the lookup table so 
that only valid values will be available for selection. This will take some of 
the guesswork and spelling mistakes out of the equation. It also allows a 
non-Access query guru to do his or her own searches. 
Creating the Query/Report Options Form 
Completed Search CDs query form 
In this lesson, we will create a form in Design View that is not bound to a 
table. Forms and objects on the form can be “bound” to a table/query or 
field, respectively, or they can be left “unbound.” The object must be bound 
if information is to be saved into a table; if it is for temporary use and not to 
be saved, it can be unbound. In this case, we are not saving anything from 
this form; we’re just using the selections as criteria for a query. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 67
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
Creating the Form 
1. On the Create Tab choose Form Design 
2. Create a combo box that pulls values from tblGenre (GenreID and 
Genre) using the combo box wizard. Notice that since the form is not 
based on a table, the wizard does not even give the option of saving the 
selection to a field. 
3. Create a combo box for Performer the same way 
4. Add text fields to create the unbound Date From and Date To fields 
5. In the Properties window for each field, rename them so they don’t 
say comboxx, etc., as we need to reference them and easily tell which 
is which. Name combo box fields starting with the prefix cbo (to denote that 
IDs are stored instead of the actual data) and text boxes to txt (not denoting 
text vs. numeric or date but rather as a Text Box on a form) 
• Open the Properties box of the Genre combo box 
• On the Other tab, under Name replace Combo0 with cboGenre 
• Repeat for the other fields using the appropriate prefixes 
○ cboPerformer 
○ txtDateFrom 
○ txtDateTo 
68 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 8: 
QUERY/ REPO R T OP T I O NS FORM 
6. Set the format of the 2 date fields to Short Date in order for the 
Calendar Control to be enabled 
7. On the Form’s Properties Format tab, set the following fields to No 
• Record Selector 
• Navigation Buttons 
• Scroll Bars 
8. Close and Save the form as frmSearch 
Creating the Queries 
1. Create a Query Design to pull all the basic CD information together 
• Tables 
○ tblCD 
○ tblGenre 
○ tblPerformer 
• Fields 
○ Title from tblCD 
○ YearReleased from tblCd 
○ CDValue from tblCD 
○ Genre from tblGenre 
○ Performer from tblPerformer 
○ DateCreated from tblCD 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 69
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
• Save the query as qrySearchbyGenre 
2. Copy the query twice as qrySearchbyPerformer and 
qrySearchbyDateCreated 
3. Open qrySearchbyGenre again in Design View 
4. Add GenreID from the Genre table to the grid. The value chosen in the 
combo box on the form relates to the GenreID. 
5. In the criteria row under GenreID right-click and choose Build 
6. In the expression builder Navigate to Forms → All Forms 
7. Select frmSearch from the list of forms 
70 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
8. In the center pane locate cboGenre and double click 
If you click once, the formula will not be added into the top box. You must 
double click on the final item you are selecting. 
9. Click OK. The path to the combo box will be stored in the criteria row. 
10.Uncheck the Show box under GenreID. We don’t need to see this field in 
the results 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 71
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
If you try to view the query results at this time you will get the following 
screen: 
It is looking for the value from the form. The query now needs to be run with 
the search form open and a genre selected in the drop down box cboGenre. 
11.Save and Close the genre version of the query 
Creating a Button for the Query 
1. Open frmSearchCDs in Design View 
2. Add button to call the Query using the button wizard 
• Select the Button from the Controls section of the Design Tab 
• Place the button on the form to the right of the Genre combo box 
• On the first window of the wizard, choose Miscellaneous then Run 
Query → Next 
72 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
• Select the Query you want the button to run: qrySearchbyGenre 
→ Next 
• Choose the Text: option for the button label and type CDs By 
Genre → Next 
Type in a meaningful name for the section of code that is created behind the 
scenes. Start with cmd then name (no spaces or special characters here). 
• For this button, type cmdCDsbyGenre → Finish 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 73
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
3. Switch to Form View and test the query by selecting a Genre from the 
drop down and pressing the button to run the query 
4. Close the Query window 
5. Close and Save the form 
Exercise 8: Set up the Performer Search for the 
Query/Report Options Form 
Editing the Performer Version of the Query 
1. Open qrySearchbyPerformer 
2. Add the PerformerID field 
3. Build the criteria in the same way as you did for GenreID 
• Right-click in the criteria line under PerformerID 
• Choose Build from the dropdown 
• Choose frmSearch in the first windowpane 
• Double click on cboPerformer in the second windowpane of the 
expression builder 
• Display window should show: 
[Forms]![frmSearchCDs]![cboPerformer] 
• Click OK. The formula will be transferred to the criteria row under 
Performer ID. 
74 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
• Uncheck Show under Performer ID 
4. Save and Close the Query 
Adding the Query Button 
1. Open frmSearch in Design View 
2. Add a button to call the Performer Query using the button wizard 
• Choose the Button from the Controls section of the Design tab 
• Drop the button to the right of the Performer field 
• Choose Miscellaneous → Run Query 
• Choose the query qrySearchbyPerformer 
• Label the button CDs By Performer 
• Name the command cmdCDsbyPerformer 
3. Test the query using the combo box and button for Performer 
4. Close the Query window 
5. Close and Save the form 
End of Exercise 8 
Editing a Query for Date Range Criteria 
1. Open qrySearchbyDateCreated 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 75
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
2. In the Date Created criteria right-click and choose Build 
• Before selecting any fields, type Between in the empty expression 
area 
• Then select frmSearch → txtDateFrom and double click to add 
it to the expression 
• Type And or select And from the buttons in the middle of the 
screen 
• Select the next field frmSearchCDs → DateTo → OK 
3. Close and Save the query changes 
4. Open frmSearch in Design View 
5. Add a button to call the performer query to the Search form 
• Choose the Button from the tool box 
• Choose Miscellaneous → Run Query 
• Choose the query qrySearchbyDateCreated 
• Label the button CDs By Date Added 
• Name the command cmdCDsbyDateAdded 
6. Test the query by filling in the From and To date fields 
7. Close the Query window 
8. Close and Save the form 
76 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 8: 
QUERY/ REPORT OP T I O NS FORM 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 77
Lesson 9 
Creating Reports Based on Dynamic 
Queries 
Lesson 9 
Informing Members of Newly Added CDs 
We will create a report based on the Search by Created Date query created 
and the Search form. We will pull all the CDs with a date created within a 
specific date range and send the report to all the club members. 
1. Click on qrySearchByDateCreated in the navigation pane 
2. Go to the Create Tab and click on Report 
Since the report by default wants to open up in preview mode, it again brings 
up the popup window asking for the Date From and Date To, just like if we try 
to view the query results without the search form open and date values filled in. 
3. Click OK on each of the Parameter Value pop-ups 
4. Edit the Report header label to read New CDs added between 
5. Add a text field below the header label 
6. In the Properties, locate the Data tab and the Control Source field 
7. Open the Expression builder 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 79
LESSON 9: 
CREAT ING REPORTS BAS ED ON DYNAMI C QU E R IES 
8. Add the DateTo and DateFrom fields using the expression builder 
to pull fields from the search form, concatenating “ and “ between 
the two dates 
9. Delete the label of the text field 
10.Use Format Painter to replicate font size from title to the date field 
• Select the Report Header Label box 
• Click on the (Format Painter), which is now active on the 
toolbar. Your Mouse pointer will now have a paintbrush beside it. 
• Click on the Date formula text box. The font and size will change to 
match. 
Note: 
To format multiple fields, double click on the Format Painter instead 
of single clicking. The paintbrush will stay on as you select each 
field. When finished, click Format Painter once to turn it off. 
11.Size and align the Date field with Title 
12.Add any spacing necessary in the labels of the fields (such as CD 
Value) 
13.Close and save the report as rptCDsByDateAdded 
80 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 9: 
CREAT ING REPORTS BAS ED ON DYNAMI C QU E R IES 
Creating a Report Button 
1. Add a button on the Search CDs form to preview the report 
• Select the button wizard from the toolbar 
• Place the button below the CDs by Date Added button 
• Choose Report Options → Open → Next 
Note: 
Always let the users view the report first and choose if they want to 
print once they have seen the report on the screen. 
• Select rptNewCDs → Next 
• In the Text area type the button name View CDs by Date Added 
Report → Next 
• Name it cmdViewCDsByDateAddedReport → Finish 
2. Type in the appropriate dates and click on the new button 
Report Distribution Options 
• Export to Word and e-mail 
• Save as an HTML page and upload 
• Print and mail 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 81
Lesson 10 
Create a New Database based on an 
Excel Spreadsheet 
Lesson 10 
Exercise 8: SNORCA Database 
The Society for Northern Observation of Rare and Common Amphibians 
currently has an Excel spreadsheet that lists contact information for 
Members, Researchers, and Students involved in the organization. They 
have asked you to create a database for maintaining this list and to allow 
better searching and reporting options. 
Requirements from the client: 
The SNORCA member database should keep track of the member 
information as seen in the Excel file. It should also allow more than one 
address per person and track member dues payment history. Accounting 
will want a report on Dues paid by Year for each member level. A general 
membership directory report is also needed, sorted by last name. 
Based on our database design skills, we have determined that we will need 
five tables: Member, Member Address, Member Address Type, Member 
Dues, and Member Level, as shown below. These have been created for you, 
as well as the relationships and referential integrity, in the snorca.accdb 
database. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 83
LESSON 10: 
CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET 
tblMember 
tblMemberAddress 
tblMemberAddressType 
tblMemberLevel 
tblMemberDues 
84 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 10: 
CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET 
Relationship diagram 
Checklist for your project: 
If you want to challenge yourself, work off this checklist only. If you want 
more instructions, then you can use the information given. The instructions 
are designed to make you think so they are not step-by-step entirely. If you 
want to see the final product, you may view the SNORCAFinal.accdb 
database. 
ƒ Set field properties on the tables for Data Integrity/Indexes 
ƒ Import the Excel file 
ƒ Use queries to split and add the data into the relational table structure 
ƒ Create the Member Level list 
ƒ Add the Members 
ƒ Create the Member Address types form/values 
ƒ Add the Member Addresses 
ƒ Add the Member Dues for Year 2007 
ƒ Create the Data Entry Forms for the rest of the tables 
ƒ Create a query that summarizes the dues paid by year and by 
member level 
ƒ Create a report that lists all members with their primary address 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 85
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
Set field properties for Data Integrity 
tblMember 
1. Add Date() to the default for DateCreated 
2. Create an Index on the MemberNumber that doesn’t allow 
duplicates 
3. Create a Combined Index on the First and Last names and the 
MemberSince fields that doesn’t allow duplicates 
tblMemberAddress 
1. Set MN as the default State 
2. Set USA as the default Country 
3. Add Date() to the default for DateCreated 
tblMemberAddressType 
1. Add Date() to the default for DateCreated 
2. Create an index on the AddressType field that doesn’t allow 
duplicates 
tblMemberDues 
1. Add Date() to the default for DateCreated 
2. Create a combined index on the MemberID and Membership Year 
fields that doesn’t allow duplicates 
tblMemberLevel 
1. Add Date() to the default for DateCreated 
2. Create an index on the MemberLevel field that doesn’t allow 
duplicates 
86 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 10: 
CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET 
Importing the Excel file 
View the Excel file SNORCA Address Database. Note the record count 
(number of rows, not including the header row). The spreadsheet will be 
imported into a temp file and then later divided up into the relational tables. 
1. From the External Data tab choose Excel 
2. Import the SNORCA Address Database spreadsheet using all the 
default options 
3. View the SNORCA Address Database Import errors table 
4. Determine the reason the Zip code field is failing 
Note: 
The row numbers refer to Excel row numbers, not the row in the 
Access table. If a field within a row fails to import, the rest of the row 
will still import. 
5. Delete both the SNORCA Address Database and SNORCA Address 
Database Import errors tables. 
6. Import the file again, this time changing the following option during 
the Spreadsheet import wizard: 
• Change the zip code field data type to Text 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 87
LESSON 10: 
CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET 
• Note the contents of the Import Errors table now 
7. Find row 57 in the Spreadsheet and determine what the error means 
and that it’s okay to continue 
8. Delete the ImportErrors table 
Use Queries to Split and Add the Data into the Relational 
Table Structure 
Note: 
No backups of the tables are needed before running the append 
queries in this case because the tables are all currently empty 
Create the Member Level list 
Rather than finding and typing the different member levels by hand, use a 
query to find a unique list of levels and append them to the Member Level 
table. 
1. Create a query in design view 
2. Add the SNORCA Address Database table using the show table 
dialog 
3. Add the Member Level field to the query grid 
4. Add Totals from the Show/Hide section of the Design Tab 
5. View the results 
6. Change the query to an Append query 
7. Append to tblMemberLevel 
8. Run the query and confirm the append 
88 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
9. Close the query and verify the records were added to 
tblMemberLevel. You do not need to save this query. 
Add the Members 
Note: 
We will use the primary key (ID) in the import table to link the 
members back to their original record in the import during queries. 
We will assign a new primary key (MemberID) as they are imported 
to the Member table. We cannot use the ID from the import table as 
they are not guaranteed to be the same as the MemberID, especially 
if the import to the member table is done more than once, the keys 
are not reused but keep going in sequence if you delete records. 
1. Add a numeric field to tblMember called OldID, this will 
temporarily store the ID from the import table for each member. It 
can be deleted once all the data is appended to their respective tables. 
2. Create a query in design view 
3. Add the SNORCA Address Database and tblMemberLevel tables 
using the show table dialog 
4. Join the tables by MemberLevel 
5. From SNORCA Address Database, add the ID, #, FirstName, 
LastName, and MemberSince fields to the query grid 
6. From tblMemberLevel, add the MemberLevelID field and view the 
results 
7. Change the query to an Append query and append to tblMember. 
Note that the # and ID fields did not find a match. 
8. Select the appropriate fields for each in the Append To line: 
ID matches to OldID 
# matches to MemberNumber. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 89
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
9. Run the query and confirm the append 
STOP! There are 27 records that won’t be appended due to a key violation (an 
index). 
10.Click No to cancel the append 
11.Close and Save the query as qryAppendMembers 
Check for Duplicates 
Check for duplicates based on the indexes that are set on the Member table 
1. Member Name (first and last combined with member since) 
• From the Create tab, choose Query Wizard 
• Choose the Find Duplicates Query Wizard 
• Choose the SNORCA Address Database table 
• Choose the FirstName and the LastName fields and the 
MemberSince field. No other fields are needed 
• Leave the default name of the query 
When the wizard is complete and shows the results you will see if there are any 
duplicate members by the first and last names 
2. MemberNumber 
• From the Create tab, choose Query Wizard 
• Choose the Find Duplicates Query Wizard 
• Choose the SNORCA Address Database table 
• Choose the # field 
• On the additional fields screen, choose the first and last name 
fields 
• Leave the default name of the query; allow it to override the prior 
find duplicates query 
When the wizard is complete and shows the results, you will see if there are any 
duplicate member numbers 
90 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
Dealing with Duplicate Records 
There are duplicate member numbers in the import file. It does not appear 
that the records are related in any way; it’s an issue of using Excel and not 
having a way to prevent duplicates. You have to decide what to do with 
these duplicate member numbers. You don’t want to run the import and 
skip these records. Either the old member numbers need to be corrected or 
we can start using the MemberID in place of the member number. Either 
way, to get the data into the table for now, we will remove the index on the 
MemberNumber field, append all the records, and note to the head of 
SNORCA membership that there is a problem that will need to be corrected 
before the database can go live. Once corrected (assigned new member 
numbers) the index needs to be put back in place to prevent this from 
happening again. The other alternative is to just eliminate the old member 
number entirely. 
1. Remove the index from the MemberNumber field in tblMember 
2. Close and save the table 
3. Go back to the query qryAppendMembers and run it 
4. Close and save the query 
5. Verify the members were added to tblMember 
6. If all the members were appended correctly, delete the “Find 
Duplicates…” query 
Create the Member Address types form/values 
Currently the excel file only has the ability to track one address per person. 
The client would like, in the future, to be able to have a primary and 
secondary address for each person. The existing address records will be 
labeled as primary. 
1. Highlight tblMemberAddressType 
2. From the Create tab, choose Multiple Items form 
3. Add the following values 
• Primary 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 91
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
• Secondary 
4. Write down which ID is assigned to Primary: _____ 
5. Switch to design view and clean up the header and field labels 
6. Close and save as frmMemberAddressType 
Add the Member Addresses 
1. Create a query in design view 
2. Add the SNORCA Address Database and tblMember tables using the 
show table dialog 
3. Join ID in the Snorca Address Database table to OldID in tblMember. 
4. Add the Address1, Address2, City, State, ZipCode, Country, 
Phone, and EmailAddress fields from tblMemberAddress and 
MemberID from tblMember, to the query grid 
5. Create a temporary field: 
• MemberAddressTypeID: xx where xx is the ID from the Primary 
address type value you wrote down in the previous section 
6. View the results 
7. Change the query to an Append query 
8. Append to tblMemberAddress 
9. Verify all fields have a match in the append to line 
10.Run the query and confirm the append 
11.Close and save the query as qryAppendAddresses and verify the 
records were added to tblMemberAddress 
92 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
Add the Member Dues for Year 2007 
The client would like to keep a running history of dues paid for each year. 
The current field holds dues paid in 2007. Append those values into the 
Member Dues table with a notation of 2007 in the Dues Year field. 
1. Create a query in design view 
2. Add the SNORCA Address Database and tblMember tables using the 
show table dialog 
3. Join ID in the Snorca Address Database table to OldID in tblMember. 
4. Add the MemberID from tblMember and 2007DuesPaid fields to 
the query grid 
5. Create a temporary field - DuesYear: 2007 
6. View the results 
7. Add criteria Is Not Null under the 2007DuesPaid field 
8. Change the query to an Append query 
9. Append to tblMemberDues 
10.Select the proper fields to append the 2007DuesPaid, and 
DuesYear fields to 
11.Run the query and confirm the append 
12.Close and save the query as qryAppendMemberDues 
13.Verify the records were added to tblMemberDues 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 93
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
Create the Data Entry forms 
Member Level 
1. Select tblMemberLevel 
2. Choose Create – Multiple Items Form 
3. Clean up the header and field labels in design view 
4. Close and Save as frmMemberLevel 
Member 
5. Select tblMember 
6. Choose Create – Form 
7. Clean up the header and field labels in design view 
8. Replace the MemberLevelID with a combo box that looks to 
tblMemberLevel for the values 
9. Drop the combo box into the grouping below the Member ID 
10.Close and Save as frmMember 
Member Address Subform 
1. Select tblMemberAddress 
2. Choose Create – Form 
3. Delete the MemberID and MemberAddressID fields 
4. Clean up the header and field labels in design view 
5. Replace the MemberAddressTypeID with a combo box that looks to 
tblMemberAddressType for the values 
6. Drop the combo box into the grouping above Address 1 
7. Close and Save as subfrmMemberAddress 
94 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
Member Dues 
1. Select tblMemberDues 
2. Choose Create – Multiple Items Form 
3. Delete MemberDuesID and MemberID 
4. Clean up the header and field labels in design view 
5. Shrink Membership Year to the left 
6. Shrink the form itself to the left 
7. Shrink all three fields towards the top 
8. Shrink the bottom of the form up to the fields 
9. Close and Save as subfrmMemberDues 
Add the Subforms to the Member Form 
1. Open frmMember in design view 
2. Select all the fields in the detail area and shrink them to the left 
3. Add subfrmMemberDues to the right of the fields 
4. Delete the label that comes with the subform 
5. Add subformMemberAddress to the bottom of the fields 
6. Delete the label that comes with the subform 
7. Do as much resizing or moving of fields or subforms as you can to 
allow you to see all of the fields on the form at one time (if possible 
based on your screen resolution) 
8. Close and save the form 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 95
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
Creating queries/reports 
Create a Query That Summarizes the Dues Paid By Year and By 
Member Level 
1. Create a query in design view 
2. Add tblMember, tblMemberLevel, and tblMemberDues 
3. Add the Member Level, MembershipYear, and AmountPaid 
fields to the grid 
4. Show the Totals 
5. Change the Totals line under Amount Paid to Sum 
6. Save the query as qryDuesbyYearAndLevel 
Create a Report That Lists All Members with Their Primary 
Address 
Create the Query 
1. Create a query in design view 
2. Add tblMember and tblMemberAddress 
3. Add the fields MemberAddressTypeID, First and Last name, 
Address 1 and 2, City, State, Zip, Country 
4. Set criteria under MemberAddressTypeID to the ID for Primary as 
found in the earlier exercise 
5. Uncheck show under MemberAddressTypeID 
6. Close and Save the query as qryMemberAddresses 
96 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
LESSON 10: 
CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 
Create the Report 
1. Select the query just created 
2. Create a report using the Report option 
3. Add a sort to the report: Last name, then first name using the Group 
and Sort option 
4. Clean up the header and labels 
5. Close and Save as rptMemberAddresses 
If everything was appended correctly and showing up in the forms, you 
may delete the Append queries and the imported table now to prevent them 
from accidentally being run again. Also delete the OldID field from 
tblMember. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 97
Using the Object Dependencies 
Feature 
A 
Appendix A 
Appendix Object Dependencies shows all the objects (Forms, queries, reports, etc.) that 
another object references or is referenced by. This can be helpful in a 
database you are taking over. You can see if you make a change to a table, 
what other objects may be affected. This feature became available in Access 
2003 
Select a table, then from the Database Tools Tab choose Object 
Dependencies. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 99
AP P E N D I X A: 
US I N G T H E OBJECT DEPENDENCI E S FEATURE 
Example: tblMember 
You can click on the plus sign to expand an item and see further 
dependencies. Clicking on an object name will open the object. 
To use this feature on a form to see which tables, queries, or subforms it 
relates to, change the option at the top of the object dependencies window to 
Objects that I depend on instead of “Objects that depend on me.” 
100 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X A: 
US I N G T H E OBJECT DEPENDENCI E S FEATURE 
Example: frmMemberCD 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 101
Appendix B 
Creating the CD Condition Lookup 
Table 
Appendix B 
The Condition lookup table is an optional lookup table of conditions to be 
assigned to each Member’s CDs. You can assign a point value to each 
condition for sorting and calculations. 
1. Create a new table called tblCDCondition 
2. Set the following options: 
• CDConditionID 
○ Primary Key 
• CDCondition 
○ Shorten size to 15 
○ Set a no duplicates index 
• PointValue 
○ Fields Size is Byte 
○ Set a no duplicates index 
• DateCreated 
○ Default Value of Date() 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 103
AP P E N D I X B: 
CREAT ING T H E CD CO N D I T I O N LOOKUP TABLE 
3. Create a maintenance form for CD Conditions 
• Create form using Multiple Items Form 
• Name the form frmCDCondition 
• Delete the CDConditionID field 
• Clean up the Header Title and field labels 
4. Enter the following condition and Point Values: 
• Poor with Point Value = 1 
• Fair with Point Value = 2 
• Good with Point Value =3 
• Excellent with Point Value = 4 
5. Add the CD condition foreign key to the Member CD table 
6. Assign conditions to CDs through frmMemberCD 
• Shrink the CD combo box about an inch and a half to the left 
• Add a CD Condition Combo box to the right of CD 
○ Add a combo box from the tool bar 
○ Select tblCDCondition 
○ Select CDConditionID and Condition 
104 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X B: 
CREAT ING T H E CD CO N D I T I O N LOOKUP TABLE 
○ Sort by Point Value 
○ Choose to store the value selected in the CDConditionID field 
○ Name the combo box Condition 
• Open the form and assign conditions to a few CDs 
Note: 
To track CD Conditions through time, place the CD condition ID in 
the CD loan table/Check In form instead of the Member CD 
Table/Form. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 105
Access Crosstab Query Wizards 
C 
Appendix C 
Appendix Crosstab queries show a summary of the data in rows and columns—similar 
to an Excel spreadsheet—with sums, counts, etc., and grand totals 
calculated. We will create a crosstab that shows the number of CDs owned 
by each member within each Genre. Since the information we would need is 
in multiple related tables, we must base this query on another query that has 
all the fields needed. 
1. Click on Create objects click Query Wizard 
2. In the New Query dialog box select Crosstab Query Wizard → OK 
3. Switch to Queries and choose qryCDListWithOwners → Next 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 107
AP P E N D I X C: 
ACCESS CROSSTAB QUERY WI Z ARDS 
4. Select Genre as the row → Next 
5. Select Owner as the Columns → Next 
108 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X C: 
ACCESS CROSSTAB QUERY WI Z ARDS 
6. The field that we want to do a calculation on is Title and the Function 
is Count. Leave the default option to include row sums (grand total 
Title count) → Next → Finish 
Results of Crosstab Query 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 109
Advanced Report Creation 
D 
Appendix D 
Appendix Creating an Overdue CD letter 
We will create a mail merge letter for each member in the club that has 
overdue CD Loans. We will ensure that one letter is sent per member by 
grouping by the member name and showing all their overdue CD loans in 
one letter. We will start by creating a query that determines which Loans are 
past due. 
1. Create a query in design view 
2. Add tblMember, tblCDLoan, tblMemberCD, tblCD and tblPerformer 
3. Remove the join between tblMember and tblMemberCD (we don’t 
care who owns the cd at this point) 
4. Create a concatenated field called LentTo and combine the first and 
last names from tblMember 
5. Select Ascending sort for Lent To 
6. Add the Title, Performer, DateOut and DateIn fields to the query 
grid 
7. Preview the query 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 111
AP P E N D I X D: 
ADVANC E D REPORT CREAT ION 
Note that we only want to pull records where the Date In is blank. Those are 
the ones currently on loan. 
Modifying the Query to Only Display Records where DateIn is 
Blank 
1. Return to Design View 
2. Add Is Null under the criteria for DateIn 
3. Add a new field to determine the DueDate and eliminate those that 
are not due yet (due date is less than today’s date) 
• DateDue: DateAdd('d',10,[dateout]) 
• In the criteria row for DateDue type <Date() 
4. Preview the query results 
5. Return to Design View and uncheck Show under DateIn 
112 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X D: 
ADVANC E D REPORT CREAT ION 
Show the address for each Member 
1. Add tblMemberAddress to the query 
2. Add the Address1, Address2, and Address3 fields to the grid 
3. Create a new concatenated field for City, State, and Zip as CSZ: 
City& “, “&State&” “&Zip 
4. Preview the query results 
Notice that there may be more than one record per person if they have more 
than one address in the database 
5. Add tblAddressType to the query 
6. Add AddressType to the grid 
7. For criteria type Home to only see their home address 
8. Uncheck Show under Address Type 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 113
AP P E N D I X D: 
ADVANC E D REPORT CREAT ION 
Note: 
If the member did not list a home address, then his or her record 
would drop out of the query. See Appendix E, Adding a Primary 
Address Indicator, regarding adding a checkbox to indicate the 
preferred address and using that as the criteria instead. 
9. Preview the query results, then close and save the Query as 
qryCDPastDue 
Creating the Past Due Report 
1. From the Create Tab choose Report Design 
2. From the Tools section choose Property Sheet 
3. From the Record Source dropdown choose qryCDPastDue 
114 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X D: 
ADVANC E D REPORT CREAT ION 
4. From the Grouping and Totals section choose Group and Sort 
5. Choose LentTo from the field list 
6. Click on More 
7. Change “without a footer section” to “with a footer section” 
8. Close the Group Sort and Total window 
Adding fields to the Report 
1. Click on Add Existing Fields in the Tools section 
2. Position LentTo, the Addresses, and CSZ fields in the newly created 
LentTo Header and arrange them so they are right on top of each 
other (simulating lining them up in a window envelope) 
3. Remove the labels from all five fields in the LentTo header 
4. Select all five fields at once, right-click, and choose Properties 
5. On the format tab set Can Shrink to Yes. If any field is blank, the fields 
below will move up rather than leave empty space in between. Except this 
seems to be a bug in 2007 and does still leave space. 
6. Add a text box from the tool box to the lower left corner of the 
LentTo header for the salutation 
7. Double click where it shows Unbound to see the properties 
8. In the field type this concatenation (including the = sign) : 
= "Dear " & [lent to] & ", " 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 115
AP P E N D I X D: 
ADVANC E D REPORT CREAT ION 
9. Add a Label from the tool box for the body of the letter and type in 
the message to the member: 
According to our records, the following CD(s) are 
overdue. Please return them to their rightful owners as 
listed immediately. If they are not returned, you will face 
accumulating fines and eventually banishment from the 
club. 
10.From the Add existing fields select Title, Performer, Date Out and 
Date Due and add them to the Detail section 
11.Shrink the detail section so there isn’t extra white space after the 
group of fields 
12. In the LentTo Footer, add label fields for the letter closing of Yours 
truly and CD Club Director, leaving space for a signature between 
116 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X D: 
ADVANC E D REPORT CREAT ION 
13.Add a Page Break, from the Controls section, to the bottom of the 
LentTo footer to ensure the next member’s letter starts on a new page. 
The page break shows as a short dotted line. 
14.Save the report as rptCDPastDue 
15.View the report, Note: report view does not show page breaks, print 
preview will display the separated pages. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 117
Appendix E 
Adding a Primary Address Indicator 
Appendix E 
If you are allowing multiple addresses in your database and not everyone 
will be required to enter a Home address or a Work address, whichever you 
are more likely to send correspondence to, you can add a Primary address 
indicator (checkbox). Use this indicator on any query that pulls the names 
addresses to return only that one address. 
1. Add the Primary field to tblMemberAddress 
2. Assign the Yes/No Data Type to create a checkbox field on a form 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 119
AP P E N D I X E: 
ADDI N G A P R I M AR Y ADDRESS I N D ICATOR 
3. Add the new field to subfrmMemberAddress using Add Existing 
Fields 
4. Go through all existing records and choose one as the primary 
address 
5. To use in any query to show only the Primary address 
• Add the Primary field 
• Set criteria to true 
• Uncheck “show” box 
120 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
Updating the Switchboard 
The Existing Switchboard 
Appendix F 
Appendix F 
The existing switchboard is at its limit of menu items. (You are only allowed 
eight items maximum per switchboard.) It would make sense at this point to 
create a multi-level switchboard that is logically divided. A return to the 
main switchboard option also needs to be added to any secondary level 
switchboards. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 121
AP P E N D I X F: 
UPDAT ING T H E S W ITCHBOARD 
Creating the List Maintenance Switchboard 
1. Open the Switchboard Manager from the Database Tools Ribbon 
2. Create a new switchboard called Reports 
• From the switchboard menu choose New 
• Name the switchboard Reports 
3. Select the Reports Switchboard and click Edit 
4. Add the following: 
• Search (open frmSearch in Edit Mode) 
• CD Master List (open respective report) 
• CDs Past Due (open respective report) 
• Member Address List (open respective report) 
• Member Address Labels(open respective report) 
• Main Menu (Go to Switchboard –> Main Switchboard) 
5. Close the edit screen 
6. Select the Main Switchboard and choose Edit 
7. Remove the 2 reports at the bottom of this switchboard 
122 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X F: 
UPDAT ING T H E S W ITCHBOARD 
8. Add a new item to open frmCDLoan in edit mode 
9. Use the Move Up button to place it after the View/Edit Members CD 
List 
10.Add another item to go to the Reports Switchboard 
11.Close the Switchboard Manager 
12.Close and reopen the database to see the new Switchboard 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 123
E-mail Forms 
G 
Appendix G 
Appendix A new feature in Access 2007 is the e-mail form. You can send an e-mail that 
has a form with fields for the recipient to fill out and return to you. You can 
have the response saved right into the table in the database. 
NOTE: 
The recipient’s e-mail program MUST allow HTML e-mails. The 
sender MUST have Outlook set up on their computer for the process 
to work. 
Because of the above limitations, this exercise cannot be done in class. For 
this example, we will be gathering member names and birthdays. The e-mail 
is based on one table but cannot make use of key fields and drop down 
boxes. Only text fields and non key number fields can be used. 
1. Click on tblMember to select it 
2. On the External Data tab click on Create E-mail 
3. On the first page of the wizard click next 
4. Leave the default of HTML form and click next 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 125
AP P E N D I X G: 
E -MAI L FORMS 
5. We want to collect new member information so leave the default and 
click next 
6. Move the desired fields into the include side, in this case, FirstName, 
MiddleName, LastName, and Birthday. MemberStatusID is a key 
field and will default to active; date created defaults to the day the record is 
added to the table. 
126 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X G: 
E -MAI L FORMS 
7. Click on each name field to edit the label of the field to put spaces 
between the words → Next 
8. Check the Automatically process replies box → Next 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 127
AP P E N D I X G: 
E -MAI L FORMS 
9. Leave the default of Enter the e-mail address in Outlook option and 
click next 
10.Change the subject line and click next 
11.On the last screen click Create 
12.The e-mail will open up in Outlook for you to enter the recipients’ 
e-mail addresses and then hit send. 
128 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
AP P E N D I X G: 
E -MAI L FORMS 
Recipients get the e-mail, hit Reply, and then fill in the fields and hit send. 
After replies are received, you will see them in a folder in Outlook called 
Access Data collection replies. 
Since we chose to automatically save them to the table, we can see the replies 
by looking at the Member form. 
UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 129

More Related Content

What's hot

Documenting sacs compliance with microsoft excel
Documenting sacs compliance with microsoft excelDocumenting sacs compliance with microsoft excel
Documenting sacs compliance with microsoft excel
Sandra Nicks
 
Access presentation
Access presentationAccess presentation
Access presentation
DUSPviz
 
Ms access tutorial
Ms access tutorialMs access tutorial
Ms access tutorial
minga48
 
Access lesson 02 Creating a Database
Access lesson 02 Creating a DatabaseAccess lesson 02 Creating a Database
Access lesson 02 Creating a Database
Aram SE
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
jigeno
 

What's hot (20)

CIS 111 STUDY Achievement Education--cis111 study.com
CIS 111 STUDY Achievement Education--cis111 study.comCIS 111 STUDY Achievement Education--cis111 study.com
CIS 111 STUDY Achievement Education--cis111 study.com
 
CIS 111 STUDY Become Exceptional--cis111study.com
CIS 111 STUDY Become Exceptional--cis111study.comCIS 111 STUDY Become Exceptional--cis111study.com
CIS 111 STUDY Become Exceptional--cis111study.com
 
Sq lite module2
Sq lite module2Sq lite module2
Sq lite module2
 
CIS 111 STUDY Education Counseling--cis111study.com
 CIS 111 STUDY Education Counseling--cis111study.com CIS 111 STUDY Education Counseling--cis111study.com
CIS 111 STUDY Education Counseling--cis111study.com
 
Documenting sacs compliance with microsoft excel
Documenting sacs compliance with microsoft excelDocumenting sacs compliance with microsoft excel
Documenting sacs compliance with microsoft excel
 
Access lesson 01 Microsoft Access Basics
Access lesson 01 Microsoft Access BasicsAccess lesson 01 Microsoft Access Basics
Access lesson 01 Microsoft Access Basics
 
Microsoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 EcdlMicrosoft Access Notes 2007 Ecdl
Microsoft Access Notes 2007 Ecdl
 
Cis 515 Effective Communication-snaptutorial.com
Cis 515 Effective Communication-snaptutorial.comCis 515 Effective Communication-snaptutorial.com
Cis 515 Effective Communication-snaptutorial.com
 
Access presentation
Access presentationAccess presentation
Access presentation
 
MS Access Training
MS Access TrainingMS Access Training
MS Access Training
 
Ms access
Ms accessMs access
Ms access
 
Access 2007-Datasheets 1-Create a table by entering data
Access 2007-Datasheets 1-Create a table by entering dataAccess 2007-Datasheets 1-Create a table by entering data
Access 2007-Datasheets 1-Create a table by entering data
 
Lecture 7: introduction to computer
Lecture 7: introduction to computerLecture 7: introduction to computer
Lecture 7: introduction to computer
 
Cis 111 Education Redefined - snaptutorial.com
Cis 111     Education Redefined - snaptutorial.comCis 111     Education Redefined - snaptutorial.com
Cis 111 Education Redefined - snaptutorial.com
 
Ms access tutorial
Ms access tutorialMs access tutorial
Ms access tutorial
 
社會網絡分析UCINET Quick Start Guide
社會網絡分析UCINET Quick Start Guide社會網絡分析UCINET Quick Start Guide
社會網絡分析UCINET Quick Start Guide
 
B.sc i agri u 4 introduction to ms access
B.sc i agri u 4 introduction to ms accessB.sc i agri u 4 introduction to ms access
B.sc i agri u 4 introduction to ms access
 
Microsoft Access 2007
Microsoft Access 2007Microsoft Access 2007
Microsoft Access 2007
 
Access lesson 02 Creating a Database
Access lesson 02 Creating a DatabaseAccess lesson 02 Creating a Database
Access lesson 02 Creating a Database
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
 

Similar to Advanced database

La6 ict-topic-6-information-systems
La6 ict-topic-6-information-systemsLa6 ict-topic-6-information-systems
La6 ict-topic-6-information-systems
Azmiah Mahmud
 
Nota database object query
Nota database object queryNota database object query
Nota database object query
Azmiah Mahmud
 
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
EzekielJames8
 
La6 ict-topic-6-information-systems
La6 ict-topic-6-information-systemsLa6 ict-topic-6-information-systems
La6 ict-topic-6-information-systems
Kak Yong
 
4 crear formularios training presentation create forms for a new database-1
4 crear formularios training presentation   create forms for a new database-14 crear formularios training presentation   create forms for a new database-1
4 crear formularios training presentation create forms for a new database-1
Aula Cloud
 
2 crear formularios training presentation - create forms for a new database
2 crear formularios   training presentation - create forms for a new database2 crear formularios   training presentation - create forms for a new database
2 crear formularios training presentation - create forms for a new database
Aula Cloud
 
Creating and editing a database
Creating and editing a databaseCreating and editing a database
Creating and editing a database
crystalpullen
 
INTRODUCTION TO ACCESSOBJECTIVESDefine th.docx
INTRODUCTION TO ACCESSOBJECTIVESDefine th.docxINTRODUCTION TO ACCESSOBJECTIVESDefine th.docx
INTRODUCTION TO ACCESSOBJECTIVESDefine th.docx
mariuse18nolet
 
Information Systems For Business and BeyondChapter 4Data a.docx
Information Systems For Business and BeyondChapter 4Data a.docxInformation Systems For Business and BeyondChapter 4Data a.docx
Information Systems For Business and BeyondChapter 4Data a.docx
jaggernaoma
 
Form5 cd6
Form5 cd6Form5 cd6
Form5 cd6
smktsj2
 

Similar to Advanced database (20)

Notacd12
Notacd12Notacd12
Notacd12
 
La6 ict-topic-6-information-systems
La6 ict-topic-6-information-systemsLa6 ict-topic-6-information-systems
La6 ict-topic-6-information-systems
 
Nota database object query
Nota database object queryNota database object query
Nota database object query
 
Notacd12
Notacd12Notacd12
Notacd12
 
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
DSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BIDSN_Power BI
 
Training MS Access 2007
Training MS Access 2007Training MS Access 2007
Training MS Access 2007
 
La6 ict-topic-6-information-systems
La6 ict-topic-6-information-systemsLa6 ict-topic-6-information-systems
La6 ict-topic-6-information-systems
 
L6-information-systems
L6-information-systemsL6-information-systems
L6-information-systems
 
Nota ict form 5
Nota ict form 5Nota ict form 5
Nota ict form 5
 
4 crear formularios training presentation create forms for a new database-1
4 crear formularios training presentation   create forms for a new database-14 crear formularios training presentation   create forms for a new database-1
4 crear formularios training presentation create forms for a new database-1
 
2 crear formularios training presentation - create forms for a new database
2 crear formularios   training presentation - create forms for a new database2 crear formularios   training presentation - create forms for a new database
2 crear formularios training presentation - create forms for a new database
 
Creating and editing a database
Creating and editing a databaseCreating and editing a database
Creating and editing a database
 
Sql Lab 4 Essay
Sql Lab 4 EssaySql Lab 4 Essay
Sql Lab 4 Essay
 
T6
T6T6
T6
 
INTRODUCTION TO ACCESSOBJECTIVESDefine th.docx
INTRODUCTION TO ACCESSOBJECTIVESDefine th.docxINTRODUCTION TO ACCESSOBJECTIVESDefine th.docx
INTRODUCTION TO ACCESSOBJECTIVESDefine th.docx
 
Database as information system
Database as information systemDatabase as information system
Database as information system
 
Access 2016 Instructor S Manual Access Module 2 Building And Using Queries
Access 2016 Instructor S Manual Access Module 2  Building And Using QueriesAccess 2016 Instructor S Manual Access Module 2  Building And Using Queries
Access 2016 Instructor S Manual Access Module 2 Building And Using Queries
 
Information Systems For Business and BeyondChapter 4Data a.docx
Information Systems For Business and BeyondChapter 4Data a.docxInformation Systems For Business and BeyondChapter 4Data a.docx
Information Systems For Business and BeyondChapter 4Data a.docx
 
Form5 cd6
Form5 cd6Form5 cd6
Form5 cd6
 
Microsoft access
Microsoft accessMicrosoft access
Microsoft access
 

Recently uploaded

Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
amitlee9823
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
amitlee9823
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
Matteo Carbone
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 

Recently uploaded (20)

Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 

Advanced database

  • 1. University Technology Training Center Access 2007: Advanced Database Development
  • 2.
  • 3. UNIVERSITY TECHNOLOGY TRAINING CENTER Access 2007: Advanced Database Development © 2009 Regents of the University of Minnesota University Technology Training Center All Rights Reserved uttc.umn.edu The University of Minnesota is committed to the policy that all persons shall have equal access to its programs, facilities, and employment without regard to race, color, creed, religion, national origin, sex, age, marital status, disability, public assistance status, veteran status, or sexual orientation. This publication/material can be made available in alternative formats for people with disabilities. Direct requests to: University Technology Training Center 190 Shepherd Labs 100 Union Street Southeast Minneapolis, MN 55455 612.625.1300 uttc@umn.edu 4 . 3 0 . 0 9
  • 4.
  • 5. Table of Contents LESSON 1 1 INTRODUCTION 1 Database Design Vocabulary Review 1 Relationships as of the Access 2007 Basics Class 3 Security Options 3 Design Mode vs. View Mode Refresher 4 LESSON 2 5 IMPROVING THE EXISTING DATABASE 5 Improvements and Additions 5 Creating a New Table and Setting Properties 6 Appending Data from tblMemberCD to tblCDLoan 8 LESSON 3 13 UPDATING RELATIONSHIPS 13 Updating Relationships 13 LESSON 4 17 DATA INTEGRITY 17 Additional Data Integrity Checks at the Table Level 17 Creating Validation Rules 17 Exercise 1: Creating Field Level Validation Rules 21 Using Indexes to Prevent Duplicates 23 Exercise 2: Creating No Duplicates Indexes 25 LESSON 5 27 EDITING FORMS AND COMBO BOXES 27 Combo Boxes 27 Exercise 3: Editing Combo Boxes 32 LESSON 6 35 ADVANCED FORM CREATION 35 Handling of CD Loans 35 Create Query that the Main Form Will Be Based Upon 36 Create the Main Form Showing All CDs and Their Owners 37 Exercise 4: Creating a Subform 39 Adding a Search Combo Box to the Main Form 43 LESSON 7 47 IMPORTING DATA INTO AN ACCESS DATABASE 47 Adding a New Member to the Club 47 Exercise 5: Adding New Genres to the Genre Table 55 Adding new CDs to the Database 57 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER I
  • 6. Exercise 6: Assigning CDs to the New Member 59 Reusing Action Queries 61 Exercise 7: Importing Excel Data Using an Existing Set of Append Queries 61 LESSON 8 67 QUERY/REPORT OPTIONS FORM 67 Creating the Query/Report Options Form 67 Exercise 8: Set up the Performer Search for the Query/Report Options Form 74 LESSON 9 79 CREATING REPORTS BASED ON DYNAMIC QUERIES 79 Informing Members of Newly Added CDs 79 LESSON 10 83 CREATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 83 Exercise 8: SNORCA Database 83 APPENDIX A 99 USING THE OBJECT DEPENDENCIES FEATURE 99 Example: tblMember 100 Example: frmMemberCD 101 APPENDIX B 103 CREATING THE CD CONDITION LOOKUP TABLE 103 APPENDIX C 107 ACCESS CROSSTAB QUERY WIZARDS 107 APPENDIX D 111 ADVANCED REPORT CREATION 111 Creating an Overdue CD letter 111 APPENDIX E 119 ADDING A PRIMARY ADDRESS INDICATOR 119 APPENDIX F 121 UPDATING THE SWITCHBOARD 121 Creating the List Maintenance Switchboard 122 APPENDIX G 125 E-MAIL FORMS 125 I I UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 7. Introduction 1 Lesson 1 Lesson In this class, we will expand on the skills used in the Basics class by making improvements to the CD Club database. We will pick up right where we left off, with a workable but simple database for tracking the loaning of CDs between members of the CD Club. In making changes to this database we will learn what effects those changes have to existing data, tables, forms, queries, and reports. Database Design Vocabulary Review Databases ƒ Field: One piece of information you want to track in your database o Examples: Name, Birth Date, CD Title, etc. ƒ Record: A group of fields containing data about one particular person, event, item, etc. o Examples: CD Title—Artist—Genre—Release Year ƒ Table: A group of records Best Practice When you expect multiple values or repeating data in a table, you should consider splitting the table into two or more related tables. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 1
  • 8. LESSON 1: I NTRODUCTION Relationships Types of Relationships ƒ One-to-Many: The most common type. For every record in Table A, there are multiple records in Table B. o Example: One Member may have many Addresses (work, home, cabin, etc.) ƒ Many-to-Many: For every record in Table A, there are multiple records in Table B, and vice versa. In this case, a third table—called a Join Table—needs to be created that will contain only unique values. o Example: One Member may have many CDs, and the same CD may be owned by many Members Best Practice The Join Table name should be a combination of the two many-to-many tables (e.g., tblMemberCD). ƒ One-to-One: The rarest type, it is used for security and organization (i.e., avoiding empty fields that only apply to some records in the table) ƒ Primary Key: Auto-numbered, unique ID for internal database use and in matching records between related tables ƒ Foreign Key: A number-type field in a related table pointing back to the Primary Key in another table Best Practice The Primary Key should be the table name plus “ID” (e.g., MemberID) and should be the same name in a related table where it is used as a Foreign Key. (There are exceptions. In this course, the Foreign Keys LoanedToID and MemberID in tblMemberCD table both go back to the Primary Key MemberID in tblMember.) The Primary Key for a Join Table can be the Join Table name or the first initial of each table name followed by ID (e.g., MemberCDID). 2 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 9. LESSON 1: I NTRODUCTION Relationships as of the Access 2007 Basics Class Security Options New in Access 2007 This small menu bar replaces the security popup window in Access 2003. In mid-March 2008 an Office 2007 service pack was released and the warnings have gone away completely. If you don’t have the service pack installed, you will want to click on Options and choose the “Enable this Content” radio button if you have any Macros, Action Queries, or VBA code in the database. Otherwise, you can chooose the default of “Protect me from this content.” UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 3
  • 10. LESSON 1: I NTRODUCTION Design Mode vs. View Mode Refresher For all objects we work with in this class, we will be switching back and forth between Design View of the object and the end user view or result (data sheet, form, query results, or report results). The method of changing the view is identical. From the Home tab on the ribbon, choose the first icon on the left: ƒ To switch to data sheet, form, or results ƒ To switch back to Design View 4 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 11. Improving the Existing Database Improvements and Additions 2 Lesson 2 Lesson What Improvements or Additions Can We Make to This Database? The refine and test phase of database development is an ongoing process. As the database is used, things will come up that need to be corrected or improved upon, processes or requirements may change, or you may have learned a new Access skill you wish to put to use. Working with a database that already has data entered or is in constant use adds another level of difficulty to the process. We will explore the features in Access 2007 that help make this process easier. Problem: The database currently does not retain any history of the CD loan; it only tracks if a CD is on loan at the present time. Solution: Create a separate table to record every time a CD is loaned out. Problem: Currently nothing stops you from entering duplicate data. Solution: Add indexes where needed to prevent duplicates UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 5
  • 12. LESSON 2: IMPR O V I N G T H E E X I S T I N G DATABAS E Other Additions/Changes We Could Make: ƒ Additional field properties to prevent incorrect data being entered through the forms ƒ A form for running queries/reports with dynamic criteria ƒ Importing a new member’s CDs to save data entry time Creating a New Table and Setting Properties Start by creating the new table, in Design View, needed for the additional information. Set field properties for size, format, input masks, and default values where appropriate. Best Practice Set all the field properties and options at the table level so they propagate through the forms for data entry CD Loan History This table will store every loan transaction for historical tracking. The MemberID field here corresponds to the borrower of the CD. We will not be adding input masks to the DateOut or DateIn fields so we can take advantage of the new calendar control option. Figure 1: CDLoan table in Design View 1. Open the file CDClubDay1.accdb 2. Create the fields as shown in Figure 1, above 3. Add the Date() formula into the Default Value of DateCreated 6 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 13. LESSON 2: IMPR O V I N G T H E E X I S T I N G DATABAS E Now we have a new table to store all of the CD loan transaction history. The Member CD table has existing information regarding current loans. At this point, a decision has to be made about the existing loan information: ƒ Start from scratch ƒ Populate the existing loans into the new table manually ƒ Populate the existing loans into the new table programmatically In this case, we wouldn’t want to lose track of any CDs currently on loan to other members. Reentering the data is time consuming and can lead to data entry errors, so we will opt to import the data into the new table programmatically by using a type of query called an action query, specifically an Append type of action query. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 7
  • 14. LESSON 2: IMPR O V I N G T H E E X I S T I N G DATABAS E Appending Data from tblMemberCD to tblCDLoan 1. From the Create Tab choose Query Design 2. Add tblMemberCD and close the Show Table dialog box 3. Add the following fields to the grid: • MemberCDID • LoanedToID • DateOut • DateCreated 4. Preview the query using the View Toggle Note that all CDs are listed—even ones that have never been loaned out. We only need to pull information for those CDs that are currently loaned out. 8 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 15. LESSON 2: IMPR O V I N G T H E E X I S T I N G DATABAS E Setting Criteria for the Query 1. Return to Design View using the View Toggle 2. Add Is Not Null to the Criteria under the DateOut field 3. Preview the results using the View toggle Now we have only the records we need to populate the CD Loan table. You should have 11 records showing. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 9
  • 16. LESSON 2: IMPR O V I N G T H E E X I S T I N G DATABAS E Setting Up the Append Query 1. Return to Design View 2. On the Design tab, under Query Type, choose Append 3. In the Append dialog box, choose tblCDLoan from the dropdown menu and click OK A new line will be added into the query grid—Append To. If Access finds matching fields between the query and the table being appended to, it will automatically populate this row. If the fields are named differently you would have to manually choose the matching field from the dropdown list. Note that LoanedToID does not match up with a field name in the Append To Line. That is because there is no field named LoanedToID in the CD Loan table. We called it MemberID so we have to choose that field manually. 10 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 17. LESSON 2: IMPR O V I N G T H E E X I S T I N G DATABAS E 4. Click in the Append To row under LoanedToID and use the dropdown button to select the MemberID field. Previewing the query results at this point just shows the selected records as before they were changed to an Append query. Since this is an action query we need to run the query to produce results. 5. Click the Run button to run the query. It’s next to the View Toggle. 6. Click Yes to confirm the Appending of the 11 records 7. Close and Save the query as qryAppendCDLoan FYI All action queries have different icons to distinguish them from other action queries…and most importantly from the Select queries. The Append query has the icon and will run if double clicked; it won’t just open a results set. This may have unwanted consequences to your data. Access does give you a warning before executing any action query. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 11
  • 18. LESSON 2: IMPR O V I N G T H E E X I S T I N G DATABAS E Verify Results and Remove Old Fields 1. View the contents of tblCDLoan to verify the records were appended. 2. Open tblMemberCD in design view 3. Select and Delete the LoanedToID and DateOut fields 4. Click Yes to confirm deletion of the selected fields 5. Click Yes to confirm deletion of the Indexes along with the removal of the LoanedToID field 6. Close the table and Save the design changes to tblMemberCD 7. Delete the one-time query qryAppendCDLoan 12 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 19. Updating Relationships 3 Lesson 3 Lesson Now that we have updated all the tables and fields, we need to update the relationships as well. All the new tables need to be added to the relationships window and their primary and foreign keys linked accordingly. As always, set Referential Integrity to prevent orphan records or accidental deletion of records. Updating Relationships 1. On the Database Tools Tab click on Relationships 2. Right-click in the diagram and choose Show Table 3. Add tblCDLoan 4. Link tblCDLoan to tblMemberCD by the matching Primary Key/Foreign Key field UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 13
  • 20. LESSON 3: UPDAT I N G RE LAT ION S H IPS 5. Check Enforce Referential Integrity 6. Before we couldn’t link from LoanedToID to MemberID because we already had a link from MemberID to MemberID Now that we have moved the Loaned To Member’s ID to a new table (tblCDLoan) we can now set a relationship and enforce referential integrity. 7. Link the MemberID in tblCDLoan to the MemberID in tblMember 8. Set Referential Integrity 14 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 21. LESSON 3: UPDAT I N G RELAT ION S H IPS Updated Relationships 9. Close and Save the relationship diagram UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 15
  • 22.
  • 23. Data Integrity 4 Lesson 4 Lesson Additional Data Integrity Checks at the Table Level The information we get out of a database is only as good as the information that goes in. Database developers should do all they can to ensure accurate and consistent data is entered. We have already explored a few ways to limit what can be entered into a field. Here we will discuss a few additional steps you can take. Creating Validation Rules All data entered into the field must meet the criteria given. A descriptive message can be displayed when data violates the criteria. If you create a validation rule after data has been entered into that field, Access will ask you if you want to check existing data against the validation rule. LastName and FirstName fields cannot be left blank in tblMember Changing the Required setting on the General tab from No to Yes would accomplish this task, but the violation message displayed by Access when this rule is violated is more user friendly than it used to be: UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 17
  • 24. LESSON 4: DATA INT E G R I TY Or you can use the validation rule and text option to create a custom message: 1. In Design View of tblMember choose the FirstName field 2. In the General tab of the Field Properties area at the bottom of the table design screen, locate the Validation Rule and Validation Text fields • In the Validation Rule field type Is Not Null • In the Validation Text field type First name is required 3. Repeat the process for LastName 4. Close and Save the table design changes. You will get a message to test the data against the new validation rules. Click Yes 5. Open frmMember and enter a new Record leaving the First Name and Last Name fields blank (just fill in the Birthday field) and test the error messages. 18 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 25. LESSON 4: DATA INT E G R I TY DateIn in the CD Loan table cannot occur before DateOut 1. In Design View of tblCDLoan choose the DateIn field 2. In the General tab Validation Rule type the following: The above Validation Rule looks logical—and it would be accepted initially— until you save the design changes and run the validation check against existing data. At that point you will get the following error message: You cannot reference another field in a validation rule. Instead, we will create a Table level validation rule. 3. Delete the text from the Validation Rule 4. Right-click anywhere in the empty grid area of the table design 5. From the pop-up menu, choose Properties From the Table Properties dialog box, you will see a different set of Validation Rule and Validation Text fields. These rules are applied and must be met before the record can be saved. Now we can reference fields in the table. (You can check values of fields within the same record but not between two different records or other tables.) UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 19
  • 26. LESSON 4: DATA INT E G R I TY 6. In the Validation Rule field type [DateIn]>=[DateOut] (note: brackets are required) 7. In the Validation Text field type Date checked in cannot be prior to date checked out • This is what the message will look like on the form we create later in class: 8. Close and save the table design changes. Click Ok on the validation error message. 20 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 27. LESSON 4: DATA INT E G R I TY Exercise 1: Creating Field Level Validation Rules CD Title in tblCD Cannot Be Left Blank 1. Open tblCD in design view 2. In the Title field’s Validation Rule type is not null 3. In the Validation Text type CD Title is Required CDValue in CD Table Must Be a Positive Dollar Amount Greater Than Zero 1. In the CDValue field’s Validation Rule field type >0 and is not null 2. In the Validation Text field type Value greater than 0 is required 3. Close and save the Table design changes 4. Test both the title and value validation rules using the CD form UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 21
  • 28. LESSON 4: DATA INT E G R I TY DateOut and DateIn Fields in the CD Loan Table Cannot Be In The Future 1. Open tblCDLoan in design view 2. In the Validation Rule field of DateOut type <=Date() 3. In the Validation Text field type Date Out cannot be in the future 4. Repeat for DateIn field No form has been created to test this yet. It will be tested at a later time. 5. Close and save the table design changes, click OK on the validation error message. End of Exercise 22 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 29. LESSON 4: DATA INT E G R I TY Using Indexes to Prevent Duplicates Indexes are used by a database to sort and find records. You don’t want to index every field; this would create excess overhead and bog down the database. Only index fields you would most often search by. Primary Keys are automatically indexed and are unique, but the actual data is not. Access also gives you the option to require unique values as part of an index. There are many fields for which you would want to ensure unique values (especially fields in lookup tables). In the field properties area of table design there is an Indexed line. The options given in the dropdown are: ƒ No This is the default ƒ Yes (Duplicates OK) ƒ Yes (No Duplicates) To ensure unique values in the following fields, set the Indexed option to Yes (No Duplicates). Creating an Index over a Single Field 1. Performer in lookup table tblPerformer 2. Genre in lookup table tblGenre UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 23
  • 30. LESSON 4: DATA INT E G R I TY Creating an Index over Multiple Fields You can also create an index over multiple fields. We need to do this in the Member table to prevent a person from being entered into the database twice. We will use a combination of First and Last Names. Middle name is often left blank so John Smith and John A Smith would be allowed as separate records. If we use Birthday in place of Middle name we will have better duplicate prevention. 1. Open tblMember in Design View 2. Click on the Indexes button in the Design Tab. The Indexes dialog box will open with PrimaryKey and MemberStatusID already showing 3. Type MemberName in the next empty cell in the Index Name column 4. Select the LastName field from the dropdown under Field Name 5. Change Unique to Yes in the lower Index Properties section 6. On the next line, leave the index name blank (telling Access this is part of the index above) and select FirstName 24 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 31. LESSON 4: DATA INT E G R I TY 7. On the next line repeat for Birthday 8. Close the Indexes screen 9. Close and Save tblMember Exercise 2: Creating No Duplicates Indexes Index on Single Fields 1. MemberStatus in lookup table tblMemberStatus 2. AddressType in lookup table tblAddressType Index on Multiple Fields For the CD records, we could just put an index on the Title field, but that could cause issues with 2 Performers having the same title. Instead we will do a combination of Title, Performer, and Year Released as our duplicate prevention. 1. Open tblCD in Design View 2. Click on the Indexes button in the Design Tab UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 25
  • 32. LESSON 4: DATA INT E G R I TY The Indexes dialog box will open with PrimaryKey, PerformerID, and GenreID already showing 3. Type PerfTitleYear in the next empty cell in the Index Name column 4. Select the PerformerID field from the dropdown under Field Name 5. Change Unique to Yes in the lower Index Properties section 6. On the next line, leave the index name blank (telling Access this is part of the index above) and select Title 7. On the next line repeat for YearReleased 8. Close the index screen 9. Close and Save the Table End of Exercise 26 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 33. Editing Forms and Combo Boxes 5 Lesson 5 Lesson Combo Boxes You may have noticed that combo boxes—even though they may have many fields displayed when you click on the dropdown—only display the first field once you make a selection. Sometimes it would be helpful to see more information in the combo box. You can accomplish this by editing the combo box Row Source. (You can’t go back to the wizard after a combo box is created.) Be sure you still have the primary key field as the first field in the combo box or your selection won’t be saved correctly into the table. Editing Combo Boxes Show Title and Performer on Member CD Form Combo Box 1. Open frmMemberCD in Design View Oops! Notice the green triangles in the upper left corners of the Loaned To and Date Out fields. These fields are no longer valid because we removed them from the table tblMemberCD (which this form is based on) and are now in tblCDLoan. 2. Delete the two invalid fields from the subform UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 27
  • 34. LESSON 5: E D I T I N G FORMS AN D COMB O BOXES 3. Expand the CD field to fill the width of the form 4. Now we can edit the combo box. Right-click on the field and choose properties 5. In the Data Tab → Row Source, click on the (ellipses) button to pull up the query that is created behind the combo box Note: This query only exists within the context of the form; there is no saved query object in the objects window. If it were a saved query, you would see the query name (qryXXXX) rather than the SQL query statement (i.e., SELECT * FROM tbl….) 6. Use the Show Table option to add tblPerformer to the query design 7. Concatenate the Performer name to the Title field: Change the existing Title field to CD: [Title] & “ by “ & [performer] Note: the second [Title] field is used for sorting, this came from the query wizard and shows up this way in 2007 only. 8. Close the query and Save your changes 28 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 35. LESSON 5: E D I T I N G FORMS AN D COMB O BOXES Important Notes! Don’t click on Save to close the query or it will prompt you to create a query object outside of the form Be careful not to change the order or amount of fields or remove the CDID from the query. Edit the Format of the Combo Box and the Form 1. Widen the column that contains the new combined field • Switch to the Format tab of the Combo Box • In the Column Width line, there are three numbers. ○ The first is 0 because it is the hidden Primary Key field ○ The second is the newly concatenated CD title and performer column. Change the value from 1.8438 to 4 ○ Change the list width to Auto 2. Close the properties window UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 29
  • 36. LESSON 5: E D I T I N G FORMS AN D COMB O BOXES 3. Switch to Form view to see the changes to the combo box content Instead of having the CD label at the left of the field, repeated for each field, we can move it to the top of the subform easily using one of the new Arrange options 4. Switch back to design view 5. Select the CD combo box 6. On the Arrange tab choose Tabular The label will move to the Header section of the form: 30 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 37. LESSON 5: E D I T I N G FORMS AN D COMB O BOXES 7. Switch to form view to see the change 8. Close and Save the form UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 31
  • 38. LESSON 5: E D I T I N G FORMS AN D COMB O BOXES Exercise 3: Editing Combo Boxes Show Title and Performer on the CD Form’s combo box 1. Open frmCD in Design View 2. Right-click on the Find CD Combo box field and choose Properties 3. Click on the Data tab 4. Click once in the Row Source line 5. Click on the ellipses button at the end of the row 6. Add the Performer table to the query 7. Concatenate the Performer field at the end of the Title to look like this: CD: [Title] & " by " & [performer] 8. Close and Save the changes to the query 9. In the Properties window for the combo box, adjust the width of the combo box using the Format Tab to allow for the combined field. • Change the Column Width (the second value) from 3.3334 to 4 • Change the List Width to Auto 32 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 39. LESSON 5: E D I T I N G FORMS AN D COMB O BOXES 10.View and test your changes on the form (drop down the combo box) 11.Close the form and Save your design changes End of Exercise UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 33
  • 40.
  • 41. Advanced Form Creation 6 Lesson 6 Lesson Handling of CD Loans A new loan table was created in order to keep the history of all CD loan transactions, rather than just the current status of the CDs. Now, a new form needs to be created to handle these transactions. In class, we will look at this form in the simplest approach. See the appendix for separate forms for processing the transactions (check out, check in) and seeing the entire loan history for a CD. Completed CD Loan form UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 35
  • 42. LESSON 6: ADVANC E D FORM CREAT ION Create Query that the Main Form Will Be Based Upon For the main part of this form we need to pull in the information pertaining to the individual CDs, as well as who owns that particular copy, and display it in a read-only fashion. We already have a query—created in the Access Basics class—that pulls this information together. We will make a copy of that query to use on this form. Copy a similar Query and Edit in Design View 1. In the Queries objects, find the query called qryCDListWithOwners 2. Right-click on this query and copy 3. Click in the queries area and choose paste 4. Name the copy: qryCDLoanMain 5. Right-click on the query and choose Design View Note that we have the following fields pulled into the query grid: o Title o YearReleased o Genre o Performer o A temporary concatenated field: Owner: LastName &”, “& FirstName Additionally we need to have the MemberCDID in the query grid (as it is the primary key/foreign key link between the CDs (tblMemberCD) and the Loans (tblCDLoan), which will be displayed in the subform). 36 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 43. LESSON 6: ADVANC E D FORM CREAT ION 6. Drag the MemberCDID from tblMemberCD and place it in the FIRST column of the query grid (in front of the Title field) Note: We don’t need to pull in the loan information at this point; it will be in the subform. 7. Add a sort to this query by choosing Ascending in the sort row in the Title Column 8. Close and Save the query design changes Create the Main Form Showing All CDs and Their Owners 1. With the qryCDLoanMain selected, click on the Create tab and then click on Form 2. Switch to design view 3. Click outside of the grouped fields to deselect them UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 37
  • 44. LESSON 6: ADVANC E D FORM CREAT ION 4. Edit the header Label to read CD Loans 5. Delete the MemberCDID field 6. Put a space in the YearReleased label 7. Edit field Properties • Select all of the fields in the detail section at once (not the labels) • Right-click on the group and choose Properties • On the Data tab, set Enable to No and Locked to Yes (to disable both selecting and editing of these fields) 8. Edit form Properties • Right-click the black box in the upper left corner of the form and choose Properties • Click on the Format tab • Change the Record Selectors option to No ○ Users won’t be editing or deleting any records in the main form. 9. Close the Properties window 10.Switch to Form view 11.Close and save the form as frmCDLoan 38 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 45. LESSON 6: ADVANC E D FORM CREAT ION Exercise 4: Creating a Subform In this exercise, you will create the subform for the Loan transactions for each CD in the main form and then link it to the main form. Creating the Subform 1. Select tblCDLoan from the table list 2. From the Create tab choose Multiple Items 3. Switch to design view and deselect the group 4. Change the Label in the header to read Loan History 5. Delete the unneeded key fields: CDLoanID, MemberCDID, and MemberID (memberID will later be replaced with a combo box) 6. Delete the Date Created field (we will end up with too many date fields and it will most often be the same as the Date Out) 7. Create a combo box for Loaned to using the Combo Box wizard • Select the Combo Box from the Controls section of the design tab and drop it to the right of the other fields in the detail section UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 39
  • 46. LESSON 6: ADVANC E D FORM CREAT ION • Choose the I want the combo box to look up the values in a table or query option (first one) → Next • Choose tblMember • Select the following fields: ○ MemberID ○ LastName ○ FirstName • Click Next • Sort by LastName, then FirstName → Next • Adjust fields as needed → Next • Choose to store that value in the field: MemberID → Next • Name the combo box Loaned To → Finish • Widen the field 8. Select the Combo box and move it to the left side of the detail section. As you move it over, you will see an orange bar between the other fields, if you drop it on that orange bar it will go into the grouping with the rest of the fields and the title will automatically move to the header section. 9. Add a Date Due calculated field to the subform to display the date out plus the 10 day loan period. • Add a text box from the Design Tab 40 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 47. LESSON 6: ADVANC E D FORM CREAT ION • Right-click on the field and choose Properties • On the Data tab, click in the Control Source field and click on the Expression Builder ellipses button • Starting at the left side, Choose Functions → Built-In Functions → Date/Time → DateAdd DateAdd («interval», «number», «date») will appear as your formula. The interval is the part of the date you want to add to (‘d’ for day in our case), number is the number to add to the interval (10 in our case), and date is the date field we are adding to for the calculation (dateout). The formula should look like this: DateAdd(‘d’,10,[dateout]), remove anything else that may show up in this window. • Click OK to close the expression builder • Edit the label to read Date Due UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 41
  • 48. LESSON 6: ADVANC E D FORM CREAT ION 10.Move the field to the end of the other fields, making sure you drop it on the orange bar to make it part of the group 11.Close and Save the form as subfrmCDLoan Note: No data entry should be done directly into a sub form, only once it is linked to the parent form. Link the Subform and Main form 1. Open the main form frmCDLoan in Design View and insert the subform • From the Controls section of the Design Tab select the (Subform) icon • Click below the Owner field where you want the subform to be placed • Using the Subform wizard choose subfrmCDLoan from the list of exisiting forms. • Choose to link the forms by the common key field MemberCDID • Click Finish 2. Delete the label that says subfrmCDLoan 3. Make the subform taller so more records can be displayed 4. Switch to form view to see the results 5. Loan a CD out to someone and verify the Date Due calculation is working 6. Close and Save your design changes 42 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 49. LESSON 6: ADVANC E D FORM CREAT ION frmCDLoans with subform Adding a Search Combo Box to the Main Form 1. Open frmCDLoan in design view 2. Below the “CD Loans” label in the header area, create a Combo box to lookup the CDs • Add a combo box to the header from the Toolbox • Choose the third option, Find a record on my form… • Choose all fields • Click Next Because we based the form on a query that pulls in multiple tables, it does not automatically hide the key field (MemberCDID), so we must manually shrink that field so it does not show. The Title field should also be expanded. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 43
  • 50. LESSON 6: ADVANC E D FORM CREAT ION Before: After: 1. Click Next 2. Name the Combo box Find CD 3. Click Finish 4. Change the text of the “Find CD” label to bold 5. Widen the unbound combo box to the width of the form 44 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 51. LESSON 6: ADVANC E D FORM CREAT ION 6. Switch to form view and test the drop down 7. Close and Save the form End of Exercise UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 45
  • 52.
  • 53. Importing Data into an Access Database 7 Lesson 7 Lesson Adding a New Member to the Club Ideally, you want to automate as much as possible in the database to save time and typing. Adding a new member’s list of CDs is a good place to use automation. Assume you give the new member an Excel template for him/her to enter all of his/her CDs. This includes value and year released. The new member can enter any appropriate values into Performer and Genre. We will import the data into a temp table and use action queries to check the data for new values and place it in the appropriate relational tables. The action queries created in this exercise can be used over and over. Use CDClubDay2 Add the new Member 1. Open frmMember 2. Go to a new record and add Peppermint Patty ○ Birthday : 3/17/1976 ○ Home Address: 123 Sir Charles Lane, St Paul, 55107 • Take note of the MemberID assigned to her 3. Close the form UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 47
  • 54. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE Import from Excel Spreadsheet template 1. On the External Data tab in the Import section choose Excel 2. Browse to Desktop → Access 2007 Advanced → Class Files folder 3. Select Peppermint Pattys Music Collection Excel file 4. Select import the source data into a new table in the current database 5. Click OK and the Import Spreadsheet wizard will appear 48 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 55. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 6. Click Next The first row contains column headings and should be checked, as we have the Field names in the first line of our Excel template. 7. Click Next No additional field formatting needs to be done (using this screen you could skip fields, change data types, rename fields or set indexes) 8. Click Next UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 49
  • 56. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 9. Since this is just a temporary table, choose No primary key and click Next 10.Save the table as tblNewCDList (keep the name generic as it will be reused for all imports of CDs into the club) 11.Click Finish → Close. We don’t need to save the import steps; they will be different next time. Note that there are 25 CDs to be added for this member. At this point you can start to divvy the fields up into their respective tables. First we need to determine if there are new Performers or Genres that need to be added to the lookup tables. Create a query to match up the Performers from the existing Performer Table 1. Right-click on tblPerformer 2. Choose Copy then Paste to make a backup copy of the table to be appended to 3. From the Create tab choose Query Design 4. Add tblNewCDList 5. Add tblPerformer 50 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 57. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 6. Link by the performer fields (to match up the performer names in the 2 tables) 7. Pull the Title and Performer fields from tblNewCDList 8. Preview the query to see the matches found Of the 25 CDs only 3 matching performers are found in our database, the rest will need to be added. Determine Missing Performers and add them to tblPerformer 1. Return to the query design 2. Right-click on the relationship line between the performer fields and choose Join Type UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 51
  • 58. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE By default, a relationship between two tables ONLY brings back records where a match is found both tables. We want to see where there isn’t a match in one of the tables (tblPerformer). We need to choose option 2 or 3, which one you need will vary. A way to remember which to choose is the first table in the statement is the one you know has the values in it (tblNewCDList) and the second table in the statement is the one where values may be missing (tblPerformer) 3. Choose option 2: Include all records from tblNewCDList and only those records from tblPerformer where the joined fields are equal 4. Click OK 5. Add the Performer field from tblPerformer to the grid 6. Preview the results All 25 CDs are showing again. Those with a blank Performer field are the Performers that need to be added. 52 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 59. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 7. Return to Design View and remove the Title field (it was only there for reference, we only want to look at the performers now) 8. Add Is Null to the criteria under tblPerformer.Performer (to see only the missing performer matches) View the query results again. We now see only the missing performer records, but there are duplicates Grouping the Performer names to get a unique list 1. Return to design view 2. From the Show/Hide section of the Design Tab, click Totals (to group by Performer and not show duplicates) 3. Change Group By to Where under tblPerformer.Performer (the one we need just for criteria purposes) UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 53
  • 60. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 4. Uncheck Show under tblPerformer.Performer 5. View the query Now you have the list of the 11 missing performers to add. 6. From the Design Tab choose the Append query type 7. Choose tblPerformer from the drop down 54 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 61. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 8. Delete Performer in the Append To line under tblPerformer.Performer Only the Performer name from the New CD list can be used in the Append operation. The second Performer field is there only for the criteria of locating the non matching records. Running the Query 1. Run the query using the Exclamation button 2. Click yes to Confirm appending 11 rows 3. Save the query as qryAppendNewPerformers 4. Verify the additions of the 11 new performers using the Performer form Exercise 5: Adding New Genres to the Genre Table Match Up Genres to Find Missing Values 1. Copy and Paste tblGenre and to make a backup 2. Create a new Query Design 3. Add tblNewCDList 4. Add tblGenre 5. Link on the Genre fields 6. Pull Genre from both tables into the query grid UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 55
  • 62. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 7. Change the join type so all records are pulled from tblNewCDList and only those with matching records in tblGenre 8. Type Is Null in the criteria under the Genre field from tblGenre and uncheck Show 9. From the Show/Hide section choose Totals 10.Change the Total option under tblGenre.Genre from Group By to Where 11.Preview the query You should have just the 3 missing genres Finish and Run the Append Query 1. Return to Design View and change the query to an Append Query type 2. Append to tblGenre 3. Remove Genre from the append line for the Genre field from tblGenre 56 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 63. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 4. Run the Query using the ! 5. Confirm the Appending of three records 6. Save the query as qryAppendNewGenres 7. Verify the three were added using the Genre form End of Exercise Adding new CDs to the Database Now we will create a query to match up the Performer and Genre fields to replace with the corresponding IDs (foreign keys), which are the values actually stored in the CD table. 1. Right click on tblCD and choose copy, then paste (to make a backup) 2. Create a new Query Design 3. Show tblNewCDList, tblGenre, tblPerformer 4. Join tables by the Performer and Genre value fields as before (so we can eventually find the corresponding Key values that are assigned to them) 5. From tblNewCDList, add the Title field 6. From tblPerformer, add the PerformerID field 7. From tblGenre, add the GenreID field 8. From tblNewCDList, add the Value and Year Released fields UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 57
  • 64. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 9. Preview and verify all 25 CDs are listed The query results are now showing keys for Performer and Genre so the fields now match up to the tblCD design Setting Up the Append Query 1. Change the query to an Append query 2. Append to tblCD Notice that Year Released and value fields do not have a corresponding field in the Append To Line. Access will automatically find matching fields if they are spelled the same. In this case Year Released from our temp table and formerly the Excel template has a space between the words and Value had to be called CD value to avoid using an access key word. We need to manually select the correct field for each to append to or these fields will be skipped. 3. In the Append To line under Year Released select the appropriate field from the table we choose to append to, YearReleased 4. In the Append To line undervalue select the appropriate field from the table we choose to append to, CDValue 58 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 65. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 5. Run the query 6. Click yes to confirm appending 25 rows 7. Save the query as qryAppendNewCDs 8. Verify the CDs were added correctly using the CD Form Exercise 6: Assigning CDs to the New Member Create a Query to add the newly created CDIDs to the members list of owned CDs stored in tblMemberCD 1. Copy and paste tblMemberCD to create a backup copy 2. Create a New Query using Query Design 3. Add tblNewCDList and tblCD 4. Join by the Title field and the Year Released field (in case there would be the same title by a performer from different years) 5. Select CDID and Title fields from tblCD 6. Preview the query and verify the correct 25 CDs are returned in the query results and return to Design View Autofill the MemberID and Append 1. Remove the Title Field 2. We have 2 options for getting the Member ID assigned to this list of CD’s UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 59
  • 66. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE • Option 1: AutoFill the newly created MemberID for each CD record. In the next available column, create a new field MemberID: xx (where xx = the ID you noted when adding Peppermint Patty to the Member form) Or • Option 2: Ask the person running the query what ID to use. In the next available column, create a new field MemberID: [Please Enter the MemberID]. This option is preferred as it will prompt you to have the correct MemberID and save you from forgetting to change it before you run it for the next person. 3. Change the query to an Append query 4. Append to tblMemberCD 5. Run the query 6. Fill in Peppermint Patty’s MemberID 7. Click Yes to confirm appending 25 records 8. Save the query as qryAppendNewMemberCDs 9. Verify results through the Member CD form 60 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 67. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 10. Delete the “copy of…” versions of tables: Genre, Performer, CD, and MemberCD End of Exercise 6 Reusing Action Queries These action queries can be used each time a new member joins, or in this case, an existing member has a large list of new CDs to add. Verify each step as you go. The only thing that needs to be changed in the queries is the MemberID in the last query. Exercise 7: Importing Excel Data Using an Existing Set of Append Queries Note: The search field at the bottom of the form is the quickest way to find a record. If a field is locked and disabled that search will not be able to look in that field. To correct that, you would have to go to the properties of the field and set Enabled to Yes (leaving locked as No) 1. What is the MemberID for Mickey Mouse ? _____ 2. How many CDs does Mickey currently have in the club? _____ UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 61
  • 68. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 3. Delete the records in tblNewCDList in datasheet view • Click in the box on the upper left corner of the table to do a Select All, then press Delete • Close the table before going on to the next step 4. Import the MickeysNewCDs.xls file from the class files folder into tblNewCDList • External Data Tab, Import section , choose Excel • Browse to MickeysNewCDs • This time choose the second radio button, Append a copy of the records to the table: • Choose tblNewCDList from the dropdown • Click ok 5. In the Import Spreadsheet Wizard click Next → Next → Finish 6. Close the import. Do not save the import process. Adding the New Performers 1. View the tblNewCDList and note the record count._____ 62 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 69. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 2. Make backup copies of tblPerfomer, tblGenre, tblCD, and tblMemberCD 3. Open qryAppendNewPerformers in Design View. Don’t double click and run it yet. 4. Preview the results and see which Performers will be added. You should have 13. 5. Switch back to Design view and Run the action query Adding the New Genres 1. Open qryAppendNewGenres in Design View (don’t double click and run it yet) 2. Preview the results and see which Genre will be added. The 1 new genre UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 63
  • 70. LESSON 7: IMPO R T I N G DATA INTO AN ACCESS DATABASE 3. Run the action query Adding the New CDs 1. Open qryAppendNewCDs in Design View. Don’t double click and run it yet. 2. Preview the results and see which CDs will be added. You should have 30. 3. Run the action query. You may get an error if some CDs already exist, click yes to continue and not add the duplicates. Assigning the New CDs to the Member 1. Open qryAppendNewMemberCDs in Design View (don’t double click and run it yet) 2. Preview the results and enter Mickeys MemberID. Verify the correct number of CDs are being assigned ownership to Mickey. He should still have 30. 3. Run the action query 4. Verify through the member CD form that all the new CDs were added to Mickey’s existing list. His existing count of CDs plus the count of newly added CDs. Clean up the tables 1. Delete the backup copies of tblGenre, tblPerformer, tblCd, and tblMemberCD 2. Delete the data (only the data, not the table) from tblNewCDList so it is ready for the next use 64 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 71. LESSON 7: IMPORT ING DATA INTO AN ACCESS DATABASE UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 65
  • 72.
  • 73. Query/Report Options Form 8 Lesson 8 Lesson Rather than having to edit the criteria of a query every time you want to run it, you can create a user-friendly form to select or enter the criteria and run the query or report based on that selection. Using dropdowns on this form not only makes it easier, but it ensures that accurately spelled and existing values are used in the criteria. The dropdowns pull from the lookup table so that only valid values will be available for selection. This will take some of the guesswork and spelling mistakes out of the equation. It also allows a non-Access query guru to do his or her own searches. Creating the Query/Report Options Form Completed Search CDs query form In this lesson, we will create a form in Design View that is not bound to a table. Forms and objects on the form can be “bound” to a table/query or field, respectively, or they can be left “unbound.” The object must be bound if information is to be saved into a table; if it is for temporary use and not to be saved, it can be unbound. In this case, we are not saving anything from this form; we’re just using the selections as criteria for a query. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 67
  • 74. LESSON 8: QUERY/ REPORT OP T I O NS FORM Creating the Form 1. On the Create Tab choose Form Design 2. Create a combo box that pulls values from tblGenre (GenreID and Genre) using the combo box wizard. Notice that since the form is not based on a table, the wizard does not even give the option of saving the selection to a field. 3. Create a combo box for Performer the same way 4. Add text fields to create the unbound Date From and Date To fields 5. In the Properties window for each field, rename them so they don’t say comboxx, etc., as we need to reference them and easily tell which is which. Name combo box fields starting with the prefix cbo (to denote that IDs are stored instead of the actual data) and text boxes to txt (not denoting text vs. numeric or date but rather as a Text Box on a form) • Open the Properties box of the Genre combo box • On the Other tab, under Name replace Combo0 with cboGenre • Repeat for the other fields using the appropriate prefixes ○ cboPerformer ○ txtDateFrom ○ txtDateTo 68 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 75. LESSON 8: QUERY/ REPO R T OP T I O NS FORM 6. Set the format of the 2 date fields to Short Date in order for the Calendar Control to be enabled 7. On the Form’s Properties Format tab, set the following fields to No • Record Selector • Navigation Buttons • Scroll Bars 8. Close and Save the form as frmSearch Creating the Queries 1. Create a Query Design to pull all the basic CD information together • Tables ○ tblCD ○ tblGenre ○ tblPerformer • Fields ○ Title from tblCD ○ YearReleased from tblCd ○ CDValue from tblCD ○ Genre from tblGenre ○ Performer from tblPerformer ○ DateCreated from tblCD UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 69
  • 76. LESSON 8: QUERY/ REPORT OP T I O NS FORM • Save the query as qrySearchbyGenre 2. Copy the query twice as qrySearchbyPerformer and qrySearchbyDateCreated 3. Open qrySearchbyGenre again in Design View 4. Add GenreID from the Genre table to the grid. The value chosen in the combo box on the form relates to the GenreID. 5. In the criteria row under GenreID right-click and choose Build 6. In the expression builder Navigate to Forms → All Forms 7. Select frmSearch from the list of forms 70 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 77. LESSON 8: QUERY/ REPORT OP T I O NS FORM 8. In the center pane locate cboGenre and double click If you click once, the formula will not be added into the top box. You must double click on the final item you are selecting. 9. Click OK. The path to the combo box will be stored in the criteria row. 10.Uncheck the Show box under GenreID. We don’t need to see this field in the results UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 71
  • 78. LESSON 8: QUERY/ REPORT OP T I O NS FORM If you try to view the query results at this time you will get the following screen: It is looking for the value from the form. The query now needs to be run with the search form open and a genre selected in the drop down box cboGenre. 11.Save and Close the genre version of the query Creating a Button for the Query 1. Open frmSearchCDs in Design View 2. Add button to call the Query using the button wizard • Select the Button from the Controls section of the Design Tab • Place the button on the form to the right of the Genre combo box • On the first window of the wizard, choose Miscellaneous then Run Query → Next 72 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 79. LESSON 8: QUERY/ REPORT OP T I O NS FORM • Select the Query you want the button to run: qrySearchbyGenre → Next • Choose the Text: option for the button label and type CDs By Genre → Next Type in a meaningful name for the section of code that is created behind the scenes. Start with cmd then name (no spaces or special characters here). • For this button, type cmdCDsbyGenre → Finish UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 73
  • 80. LESSON 8: QUERY/ REPORT OP T I O NS FORM 3. Switch to Form View and test the query by selecting a Genre from the drop down and pressing the button to run the query 4. Close the Query window 5. Close and Save the form Exercise 8: Set up the Performer Search for the Query/Report Options Form Editing the Performer Version of the Query 1. Open qrySearchbyPerformer 2. Add the PerformerID field 3. Build the criteria in the same way as you did for GenreID • Right-click in the criteria line under PerformerID • Choose Build from the dropdown • Choose frmSearch in the first windowpane • Double click on cboPerformer in the second windowpane of the expression builder • Display window should show: [Forms]![frmSearchCDs]![cboPerformer] • Click OK. The formula will be transferred to the criteria row under Performer ID. 74 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 81. LESSON 8: QUERY/ REPORT OP T I O NS FORM • Uncheck Show under Performer ID 4. Save and Close the Query Adding the Query Button 1. Open frmSearch in Design View 2. Add a button to call the Performer Query using the button wizard • Choose the Button from the Controls section of the Design tab • Drop the button to the right of the Performer field • Choose Miscellaneous → Run Query • Choose the query qrySearchbyPerformer • Label the button CDs By Performer • Name the command cmdCDsbyPerformer 3. Test the query using the combo box and button for Performer 4. Close the Query window 5. Close and Save the form End of Exercise 8 Editing a Query for Date Range Criteria 1. Open qrySearchbyDateCreated UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 75
  • 82. LESSON 8: QUERY/ REPORT OP T I O NS FORM 2. In the Date Created criteria right-click and choose Build • Before selecting any fields, type Between in the empty expression area • Then select frmSearch → txtDateFrom and double click to add it to the expression • Type And or select And from the buttons in the middle of the screen • Select the next field frmSearchCDs → DateTo → OK 3. Close and Save the query changes 4. Open frmSearch in Design View 5. Add a button to call the performer query to the Search form • Choose the Button from the tool box • Choose Miscellaneous → Run Query • Choose the query qrySearchbyDateCreated • Label the button CDs By Date Added • Name the command cmdCDsbyDateAdded 6. Test the query by filling in the From and To date fields 7. Close the Query window 8. Close and Save the form 76 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 83. LESSON 8: QUERY/ REPORT OP T I O NS FORM UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 77
  • 84.
  • 85. Lesson 9 Creating Reports Based on Dynamic Queries Lesson 9 Informing Members of Newly Added CDs We will create a report based on the Search by Created Date query created and the Search form. We will pull all the CDs with a date created within a specific date range and send the report to all the club members. 1. Click on qrySearchByDateCreated in the navigation pane 2. Go to the Create Tab and click on Report Since the report by default wants to open up in preview mode, it again brings up the popup window asking for the Date From and Date To, just like if we try to view the query results without the search form open and date values filled in. 3. Click OK on each of the Parameter Value pop-ups 4. Edit the Report header label to read New CDs added between 5. Add a text field below the header label 6. In the Properties, locate the Data tab and the Control Source field 7. Open the Expression builder UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 79
  • 86. LESSON 9: CREAT ING REPORTS BAS ED ON DYNAMI C QU E R IES 8. Add the DateTo and DateFrom fields using the expression builder to pull fields from the search form, concatenating “ and “ between the two dates 9. Delete the label of the text field 10.Use Format Painter to replicate font size from title to the date field • Select the Report Header Label box • Click on the (Format Painter), which is now active on the toolbar. Your Mouse pointer will now have a paintbrush beside it. • Click on the Date formula text box. The font and size will change to match. Note: To format multiple fields, double click on the Format Painter instead of single clicking. The paintbrush will stay on as you select each field. When finished, click Format Painter once to turn it off. 11.Size and align the Date field with Title 12.Add any spacing necessary in the labels of the fields (such as CD Value) 13.Close and save the report as rptCDsByDateAdded 80 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 87. LESSON 9: CREAT ING REPORTS BAS ED ON DYNAMI C QU E R IES Creating a Report Button 1. Add a button on the Search CDs form to preview the report • Select the button wizard from the toolbar • Place the button below the CDs by Date Added button • Choose Report Options → Open → Next Note: Always let the users view the report first and choose if they want to print once they have seen the report on the screen. • Select rptNewCDs → Next • In the Text area type the button name View CDs by Date Added Report → Next • Name it cmdViewCDsByDateAddedReport → Finish 2. Type in the appropriate dates and click on the new button Report Distribution Options • Export to Word and e-mail • Save as an HTML page and upload • Print and mail UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 81
  • 88.
  • 89. Lesson 10 Create a New Database based on an Excel Spreadsheet Lesson 10 Exercise 8: SNORCA Database The Society for Northern Observation of Rare and Common Amphibians currently has an Excel spreadsheet that lists contact information for Members, Researchers, and Students involved in the organization. They have asked you to create a database for maintaining this list and to allow better searching and reporting options. Requirements from the client: The SNORCA member database should keep track of the member information as seen in the Excel file. It should also allow more than one address per person and track member dues payment history. Accounting will want a report on Dues paid by Year for each member level. A general membership directory report is also needed, sorted by last name. Based on our database design skills, we have determined that we will need five tables: Member, Member Address, Member Address Type, Member Dues, and Member Level, as shown below. These have been created for you, as well as the relationships and referential integrity, in the snorca.accdb database. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 83
  • 90. LESSON 10: CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET tblMember tblMemberAddress tblMemberAddressType tblMemberLevel tblMemberDues 84 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 91. LESSON 10: CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET Relationship diagram Checklist for your project: If you want to challenge yourself, work off this checklist only. If you want more instructions, then you can use the information given. The instructions are designed to make you think so they are not step-by-step entirely. If you want to see the final product, you may view the SNORCAFinal.accdb database. ƒ Set field properties on the tables for Data Integrity/Indexes ƒ Import the Excel file ƒ Use queries to split and add the data into the relational table structure ƒ Create the Member Level list ƒ Add the Members ƒ Create the Member Address types form/values ƒ Add the Member Addresses ƒ Add the Member Dues for Year 2007 ƒ Create the Data Entry Forms for the rest of the tables ƒ Create a query that summarizes the dues paid by year and by member level ƒ Create a report that lists all members with their primary address UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 85
  • 92. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET Set field properties for Data Integrity tblMember 1. Add Date() to the default for DateCreated 2. Create an Index on the MemberNumber that doesn’t allow duplicates 3. Create a Combined Index on the First and Last names and the MemberSince fields that doesn’t allow duplicates tblMemberAddress 1. Set MN as the default State 2. Set USA as the default Country 3. Add Date() to the default for DateCreated tblMemberAddressType 1. Add Date() to the default for DateCreated 2. Create an index on the AddressType field that doesn’t allow duplicates tblMemberDues 1. Add Date() to the default for DateCreated 2. Create a combined index on the MemberID and Membership Year fields that doesn’t allow duplicates tblMemberLevel 1. Add Date() to the default for DateCreated 2. Create an index on the MemberLevel field that doesn’t allow duplicates 86 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 93. LESSON 10: CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET Importing the Excel file View the Excel file SNORCA Address Database. Note the record count (number of rows, not including the header row). The spreadsheet will be imported into a temp file and then later divided up into the relational tables. 1. From the External Data tab choose Excel 2. Import the SNORCA Address Database spreadsheet using all the default options 3. View the SNORCA Address Database Import errors table 4. Determine the reason the Zip code field is failing Note: The row numbers refer to Excel row numbers, not the row in the Access table. If a field within a row fails to import, the rest of the row will still import. 5. Delete both the SNORCA Address Database and SNORCA Address Database Import errors tables. 6. Import the file again, this time changing the following option during the Spreadsheet import wizard: • Change the zip code field data type to Text UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 87
  • 94. LESSON 10: CRE ATE A NEW DATABA S E B AS E D ON AN EXCEL SPREADSHEET • Note the contents of the Import Errors table now 7. Find row 57 in the Spreadsheet and determine what the error means and that it’s okay to continue 8. Delete the ImportErrors table Use Queries to Split and Add the Data into the Relational Table Structure Note: No backups of the tables are needed before running the append queries in this case because the tables are all currently empty Create the Member Level list Rather than finding and typing the different member levels by hand, use a query to find a unique list of levels and append them to the Member Level table. 1. Create a query in design view 2. Add the SNORCA Address Database table using the show table dialog 3. Add the Member Level field to the query grid 4. Add Totals from the Show/Hide section of the Design Tab 5. View the results 6. Change the query to an Append query 7. Append to tblMemberLevel 8. Run the query and confirm the append 88 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 95. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 9. Close the query and verify the records were added to tblMemberLevel. You do not need to save this query. Add the Members Note: We will use the primary key (ID) in the import table to link the members back to their original record in the import during queries. We will assign a new primary key (MemberID) as they are imported to the Member table. We cannot use the ID from the import table as they are not guaranteed to be the same as the MemberID, especially if the import to the member table is done more than once, the keys are not reused but keep going in sequence if you delete records. 1. Add a numeric field to tblMember called OldID, this will temporarily store the ID from the import table for each member. It can be deleted once all the data is appended to their respective tables. 2. Create a query in design view 3. Add the SNORCA Address Database and tblMemberLevel tables using the show table dialog 4. Join the tables by MemberLevel 5. From SNORCA Address Database, add the ID, #, FirstName, LastName, and MemberSince fields to the query grid 6. From tblMemberLevel, add the MemberLevelID field and view the results 7. Change the query to an Append query and append to tblMember. Note that the # and ID fields did not find a match. 8. Select the appropriate fields for each in the Append To line: ID matches to OldID # matches to MemberNumber. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 89
  • 96. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET 9. Run the query and confirm the append STOP! There are 27 records that won’t be appended due to a key violation (an index). 10.Click No to cancel the append 11.Close and Save the query as qryAppendMembers Check for Duplicates Check for duplicates based on the indexes that are set on the Member table 1. Member Name (first and last combined with member since) • From the Create tab, choose Query Wizard • Choose the Find Duplicates Query Wizard • Choose the SNORCA Address Database table • Choose the FirstName and the LastName fields and the MemberSince field. No other fields are needed • Leave the default name of the query When the wizard is complete and shows the results you will see if there are any duplicate members by the first and last names 2. MemberNumber • From the Create tab, choose Query Wizard • Choose the Find Duplicates Query Wizard • Choose the SNORCA Address Database table • Choose the # field • On the additional fields screen, choose the first and last name fields • Leave the default name of the query; allow it to override the prior find duplicates query When the wizard is complete and shows the results, you will see if there are any duplicate member numbers 90 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 97. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET Dealing with Duplicate Records There are duplicate member numbers in the import file. It does not appear that the records are related in any way; it’s an issue of using Excel and not having a way to prevent duplicates. You have to decide what to do with these duplicate member numbers. You don’t want to run the import and skip these records. Either the old member numbers need to be corrected or we can start using the MemberID in place of the member number. Either way, to get the data into the table for now, we will remove the index on the MemberNumber field, append all the records, and note to the head of SNORCA membership that there is a problem that will need to be corrected before the database can go live. Once corrected (assigned new member numbers) the index needs to be put back in place to prevent this from happening again. The other alternative is to just eliminate the old member number entirely. 1. Remove the index from the MemberNumber field in tblMember 2. Close and save the table 3. Go back to the query qryAppendMembers and run it 4. Close and save the query 5. Verify the members were added to tblMember 6. If all the members were appended correctly, delete the “Find Duplicates…” query Create the Member Address types form/values Currently the excel file only has the ability to track one address per person. The client would like, in the future, to be able to have a primary and secondary address for each person. The existing address records will be labeled as primary. 1. Highlight tblMemberAddressType 2. From the Create tab, choose Multiple Items form 3. Add the following values • Primary UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 91
  • 98. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET • Secondary 4. Write down which ID is assigned to Primary: _____ 5. Switch to design view and clean up the header and field labels 6. Close and save as frmMemberAddressType Add the Member Addresses 1. Create a query in design view 2. Add the SNORCA Address Database and tblMember tables using the show table dialog 3. Join ID in the Snorca Address Database table to OldID in tblMember. 4. Add the Address1, Address2, City, State, ZipCode, Country, Phone, and EmailAddress fields from tblMemberAddress and MemberID from tblMember, to the query grid 5. Create a temporary field: • MemberAddressTypeID: xx where xx is the ID from the Primary address type value you wrote down in the previous section 6. View the results 7. Change the query to an Append query 8. Append to tblMemberAddress 9. Verify all fields have a match in the append to line 10.Run the query and confirm the append 11.Close and save the query as qryAppendAddresses and verify the records were added to tblMemberAddress 92 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 99. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET Add the Member Dues for Year 2007 The client would like to keep a running history of dues paid for each year. The current field holds dues paid in 2007. Append those values into the Member Dues table with a notation of 2007 in the Dues Year field. 1. Create a query in design view 2. Add the SNORCA Address Database and tblMember tables using the show table dialog 3. Join ID in the Snorca Address Database table to OldID in tblMember. 4. Add the MemberID from tblMember and 2007DuesPaid fields to the query grid 5. Create a temporary field - DuesYear: 2007 6. View the results 7. Add criteria Is Not Null under the 2007DuesPaid field 8. Change the query to an Append query 9. Append to tblMemberDues 10.Select the proper fields to append the 2007DuesPaid, and DuesYear fields to 11.Run the query and confirm the append 12.Close and save the query as qryAppendMemberDues 13.Verify the records were added to tblMemberDues UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 93
  • 100. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET Create the Data Entry forms Member Level 1. Select tblMemberLevel 2. Choose Create – Multiple Items Form 3. Clean up the header and field labels in design view 4. Close and Save as frmMemberLevel Member 5. Select tblMember 6. Choose Create – Form 7. Clean up the header and field labels in design view 8. Replace the MemberLevelID with a combo box that looks to tblMemberLevel for the values 9. Drop the combo box into the grouping below the Member ID 10.Close and Save as frmMember Member Address Subform 1. Select tblMemberAddress 2. Choose Create – Form 3. Delete the MemberID and MemberAddressID fields 4. Clean up the header and field labels in design view 5. Replace the MemberAddressTypeID with a combo box that looks to tblMemberAddressType for the values 6. Drop the combo box into the grouping above Address 1 7. Close and Save as subfrmMemberAddress 94 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 101. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET Member Dues 1. Select tblMemberDues 2. Choose Create – Multiple Items Form 3. Delete MemberDuesID and MemberID 4. Clean up the header and field labels in design view 5. Shrink Membership Year to the left 6. Shrink the form itself to the left 7. Shrink all three fields towards the top 8. Shrink the bottom of the form up to the fields 9. Close and Save as subfrmMemberDues Add the Subforms to the Member Form 1. Open frmMember in design view 2. Select all the fields in the detail area and shrink them to the left 3. Add subfrmMemberDues to the right of the fields 4. Delete the label that comes with the subform 5. Add subformMemberAddress to the bottom of the fields 6. Delete the label that comes with the subform 7. Do as much resizing or moving of fields or subforms as you can to allow you to see all of the fields on the form at one time (if possible based on your screen resolution) 8. Close and save the form UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 95
  • 102. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET Creating queries/reports Create a Query That Summarizes the Dues Paid By Year and By Member Level 1. Create a query in design view 2. Add tblMember, tblMemberLevel, and tblMemberDues 3. Add the Member Level, MembershipYear, and AmountPaid fields to the grid 4. Show the Totals 5. Change the Totals line under Amount Paid to Sum 6. Save the query as qryDuesbyYearAndLevel Create a Report That Lists All Members with Their Primary Address Create the Query 1. Create a query in design view 2. Add tblMember and tblMemberAddress 3. Add the fields MemberAddressTypeID, First and Last name, Address 1 and 2, City, State, Zip, Country 4. Set criteria under MemberAddressTypeID to the ID for Primary as found in the earlier exercise 5. Uncheck show under MemberAddressTypeID 6. Close and Save the query as qryMemberAddresses 96 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 103. LESSON 10: CRE ATE A NEW DATABASE BASED ON AN EXCEL SPREADSHEET Create the Report 1. Select the query just created 2. Create a report using the Report option 3. Add a sort to the report: Last name, then first name using the Group and Sort option 4. Clean up the header and labels 5. Close and Save as rptMemberAddresses If everything was appended correctly and showing up in the forms, you may delete the Append queries and the imported table now to prevent them from accidentally being run again. Also delete the OldID field from tblMember. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 97
  • 104.
  • 105. Using the Object Dependencies Feature A Appendix A Appendix Object Dependencies shows all the objects (Forms, queries, reports, etc.) that another object references or is referenced by. This can be helpful in a database you are taking over. You can see if you make a change to a table, what other objects may be affected. This feature became available in Access 2003 Select a table, then from the Database Tools Tab choose Object Dependencies. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 99
  • 106. AP P E N D I X A: US I N G T H E OBJECT DEPENDENCI E S FEATURE Example: tblMember You can click on the plus sign to expand an item and see further dependencies. Clicking on an object name will open the object. To use this feature on a form to see which tables, queries, or subforms it relates to, change the option at the top of the object dependencies window to Objects that I depend on instead of “Objects that depend on me.” 100 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 107. AP P E N D I X A: US I N G T H E OBJECT DEPENDENCI E S FEATURE Example: frmMemberCD UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 101
  • 108.
  • 109. Appendix B Creating the CD Condition Lookup Table Appendix B The Condition lookup table is an optional lookup table of conditions to be assigned to each Member’s CDs. You can assign a point value to each condition for sorting and calculations. 1. Create a new table called tblCDCondition 2. Set the following options: • CDConditionID ○ Primary Key • CDCondition ○ Shorten size to 15 ○ Set a no duplicates index • PointValue ○ Fields Size is Byte ○ Set a no duplicates index • DateCreated ○ Default Value of Date() UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 103
  • 110. AP P E N D I X B: CREAT ING T H E CD CO N D I T I O N LOOKUP TABLE 3. Create a maintenance form for CD Conditions • Create form using Multiple Items Form • Name the form frmCDCondition • Delete the CDConditionID field • Clean up the Header Title and field labels 4. Enter the following condition and Point Values: • Poor with Point Value = 1 • Fair with Point Value = 2 • Good with Point Value =3 • Excellent with Point Value = 4 5. Add the CD condition foreign key to the Member CD table 6. Assign conditions to CDs through frmMemberCD • Shrink the CD combo box about an inch and a half to the left • Add a CD Condition Combo box to the right of CD ○ Add a combo box from the tool bar ○ Select tblCDCondition ○ Select CDConditionID and Condition 104 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 111. AP P E N D I X B: CREAT ING T H E CD CO N D I T I O N LOOKUP TABLE ○ Sort by Point Value ○ Choose to store the value selected in the CDConditionID field ○ Name the combo box Condition • Open the form and assign conditions to a few CDs Note: To track CD Conditions through time, place the CD condition ID in the CD loan table/Check In form instead of the Member CD Table/Form. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 105
  • 112.
  • 113. Access Crosstab Query Wizards C Appendix C Appendix Crosstab queries show a summary of the data in rows and columns—similar to an Excel spreadsheet—with sums, counts, etc., and grand totals calculated. We will create a crosstab that shows the number of CDs owned by each member within each Genre. Since the information we would need is in multiple related tables, we must base this query on another query that has all the fields needed. 1. Click on Create objects click Query Wizard 2. In the New Query dialog box select Crosstab Query Wizard → OK 3. Switch to Queries and choose qryCDListWithOwners → Next UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 107
  • 114. AP P E N D I X C: ACCESS CROSSTAB QUERY WI Z ARDS 4. Select Genre as the row → Next 5. Select Owner as the Columns → Next 108 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 115. AP P E N D I X C: ACCESS CROSSTAB QUERY WI Z ARDS 6. The field that we want to do a calculation on is Title and the Function is Count. Leave the default option to include row sums (grand total Title count) → Next → Finish Results of Crosstab Query UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 109
  • 116.
  • 117. Advanced Report Creation D Appendix D Appendix Creating an Overdue CD letter We will create a mail merge letter for each member in the club that has overdue CD Loans. We will ensure that one letter is sent per member by grouping by the member name and showing all their overdue CD loans in one letter. We will start by creating a query that determines which Loans are past due. 1. Create a query in design view 2. Add tblMember, tblCDLoan, tblMemberCD, tblCD and tblPerformer 3. Remove the join between tblMember and tblMemberCD (we don’t care who owns the cd at this point) 4. Create a concatenated field called LentTo and combine the first and last names from tblMember 5. Select Ascending sort for Lent To 6. Add the Title, Performer, DateOut and DateIn fields to the query grid 7. Preview the query UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 111
  • 118. AP P E N D I X D: ADVANC E D REPORT CREAT ION Note that we only want to pull records where the Date In is blank. Those are the ones currently on loan. Modifying the Query to Only Display Records where DateIn is Blank 1. Return to Design View 2. Add Is Null under the criteria for DateIn 3. Add a new field to determine the DueDate and eliminate those that are not due yet (due date is less than today’s date) • DateDue: DateAdd('d',10,[dateout]) • In the criteria row for DateDue type <Date() 4. Preview the query results 5. Return to Design View and uncheck Show under DateIn 112 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 119. AP P E N D I X D: ADVANC E D REPORT CREAT ION Show the address for each Member 1. Add tblMemberAddress to the query 2. Add the Address1, Address2, and Address3 fields to the grid 3. Create a new concatenated field for City, State, and Zip as CSZ: City& “, “&State&” “&Zip 4. Preview the query results Notice that there may be more than one record per person if they have more than one address in the database 5. Add tblAddressType to the query 6. Add AddressType to the grid 7. For criteria type Home to only see their home address 8. Uncheck Show under Address Type UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 113
  • 120. AP P E N D I X D: ADVANC E D REPORT CREAT ION Note: If the member did not list a home address, then his or her record would drop out of the query. See Appendix E, Adding a Primary Address Indicator, regarding adding a checkbox to indicate the preferred address and using that as the criteria instead. 9. Preview the query results, then close and save the Query as qryCDPastDue Creating the Past Due Report 1. From the Create Tab choose Report Design 2. From the Tools section choose Property Sheet 3. From the Record Source dropdown choose qryCDPastDue 114 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 121. AP P E N D I X D: ADVANC E D REPORT CREAT ION 4. From the Grouping and Totals section choose Group and Sort 5. Choose LentTo from the field list 6. Click on More 7. Change “without a footer section” to “with a footer section” 8. Close the Group Sort and Total window Adding fields to the Report 1. Click on Add Existing Fields in the Tools section 2. Position LentTo, the Addresses, and CSZ fields in the newly created LentTo Header and arrange them so they are right on top of each other (simulating lining them up in a window envelope) 3. Remove the labels from all five fields in the LentTo header 4. Select all five fields at once, right-click, and choose Properties 5. On the format tab set Can Shrink to Yes. If any field is blank, the fields below will move up rather than leave empty space in between. Except this seems to be a bug in 2007 and does still leave space. 6. Add a text box from the tool box to the lower left corner of the LentTo header for the salutation 7. Double click where it shows Unbound to see the properties 8. In the field type this concatenation (including the = sign) : = "Dear " & [lent to] & ", " UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 115
  • 122. AP P E N D I X D: ADVANC E D REPORT CREAT ION 9. Add a Label from the tool box for the body of the letter and type in the message to the member: According to our records, the following CD(s) are overdue. Please return them to their rightful owners as listed immediately. If they are not returned, you will face accumulating fines and eventually banishment from the club. 10.From the Add existing fields select Title, Performer, Date Out and Date Due and add them to the Detail section 11.Shrink the detail section so there isn’t extra white space after the group of fields 12. In the LentTo Footer, add label fields for the letter closing of Yours truly and CD Club Director, leaving space for a signature between 116 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 123. AP P E N D I X D: ADVANC E D REPORT CREAT ION 13.Add a Page Break, from the Controls section, to the bottom of the LentTo footer to ensure the next member’s letter starts on a new page. The page break shows as a short dotted line. 14.Save the report as rptCDPastDue 15.View the report, Note: report view does not show page breaks, print preview will display the separated pages. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 117
  • 124.
  • 125. Appendix E Adding a Primary Address Indicator Appendix E If you are allowing multiple addresses in your database and not everyone will be required to enter a Home address or a Work address, whichever you are more likely to send correspondence to, you can add a Primary address indicator (checkbox). Use this indicator on any query that pulls the names addresses to return only that one address. 1. Add the Primary field to tblMemberAddress 2. Assign the Yes/No Data Type to create a checkbox field on a form UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 119
  • 126. AP P E N D I X E: ADDI N G A P R I M AR Y ADDRESS I N D ICATOR 3. Add the new field to subfrmMemberAddress using Add Existing Fields 4. Go through all existing records and choose one as the primary address 5. To use in any query to show only the Primary address • Add the Primary field • Set criteria to true • Uncheck “show” box 120 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 127. Updating the Switchboard The Existing Switchboard Appendix F Appendix F The existing switchboard is at its limit of menu items. (You are only allowed eight items maximum per switchboard.) It would make sense at this point to create a multi-level switchboard that is logically divided. A return to the main switchboard option also needs to be added to any secondary level switchboards. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 121
  • 128. AP P E N D I X F: UPDAT ING T H E S W ITCHBOARD Creating the List Maintenance Switchboard 1. Open the Switchboard Manager from the Database Tools Ribbon 2. Create a new switchboard called Reports • From the switchboard menu choose New • Name the switchboard Reports 3. Select the Reports Switchboard and click Edit 4. Add the following: • Search (open frmSearch in Edit Mode) • CD Master List (open respective report) • CDs Past Due (open respective report) • Member Address List (open respective report) • Member Address Labels(open respective report) • Main Menu (Go to Switchboard –> Main Switchboard) 5. Close the edit screen 6. Select the Main Switchboard and choose Edit 7. Remove the 2 reports at the bottom of this switchboard 122 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 129. AP P E N D I X F: UPDAT ING T H E S W ITCHBOARD 8. Add a new item to open frmCDLoan in edit mode 9. Use the Move Up button to place it after the View/Edit Members CD List 10.Add another item to go to the Reports Switchboard 11.Close the Switchboard Manager 12.Close and reopen the database to see the new Switchboard UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 123
  • 130.
  • 131. E-mail Forms G Appendix G Appendix A new feature in Access 2007 is the e-mail form. You can send an e-mail that has a form with fields for the recipient to fill out and return to you. You can have the response saved right into the table in the database. NOTE: The recipient’s e-mail program MUST allow HTML e-mails. The sender MUST have Outlook set up on their computer for the process to work. Because of the above limitations, this exercise cannot be done in class. For this example, we will be gathering member names and birthdays. The e-mail is based on one table but cannot make use of key fields and drop down boxes. Only text fields and non key number fields can be used. 1. Click on tblMember to select it 2. On the External Data tab click on Create E-mail 3. On the first page of the wizard click next 4. Leave the default of HTML form and click next UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 125
  • 132. AP P E N D I X G: E -MAI L FORMS 5. We want to collect new member information so leave the default and click next 6. Move the desired fields into the include side, in this case, FirstName, MiddleName, LastName, and Birthday. MemberStatusID is a key field and will default to active; date created defaults to the day the record is added to the table. 126 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 133. AP P E N D I X G: E -MAI L FORMS 7. Click on each name field to edit the label of the field to put spaces between the words → Next 8. Check the Automatically process replies box → Next UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 127
  • 134. AP P E N D I X G: E -MAI L FORMS 9. Leave the default of Enter the e-mail address in Outlook option and click next 10.Change the subject line and click next 11.On the last screen click Create 12.The e-mail will open up in Outlook for you to enter the recipients’ e-mail addresses and then hit send. 128 UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER
  • 135. AP P E N D I X G: E -MAI L FORMS Recipients get the e-mail, hit Reply, and then fill in the fields and hit send. After replies are received, you will see them in a folder in Outlook called Access Data collection replies. Since we chose to automatically save them to the table, we can see the replies by looking at the Member form. UN I V E R S I T Y TECHNOLOGY TRAI N I N G CENTER 129