Jan's Working with Databases:

Append Query


Home > Jan's CompLit 101 > Working with Databases > Appendix

Example: Append Query

The query Append to Scores - Pick A/T in the LanguageArtsClasses database creates a partial record in the Scores table for each student for the Assignment/Test ID number that you enter. (There must already be a matching record in the Assignment/Test table.)

Problem: Each assignment or test needed a record in Scores for each of the 92 students. Boring to create all 92 manually!

Solution: Use a query to create partial records automatically. The teacher (me!) enters an ID number for the assignment or test. Running the query adds a record to Scores for each student for the selected assignment or test. There are no scores yet. After running this append query, I could then open the Scores table and finish the newly appended records by typing in a score for each student.

Steps in the process:

About the blank fields: The LetterGrade values are added later with an Update query, which we will look at shortly. The Ignore? field is a Yes/No field that would normally be blank. A Yes in this field would mean that the score would not be included in averages.

Icon: ConfusionPoint of Confusion = Disadvantage: Unnecessary records are created by this append query if the assignment or test was not actually assigned to all classes! A/T ID 87 is an example of this. Assignment 87 was a spelling test that was not assigned to class D for scheduling reasons at the end of the year. The C/S ID value of 8 is the code for class D and Spelling. So, the records for assignment 87 and C/S ID value of 8 have no score.

The unwanted records could be deleted manually or by using a Delete query.

AutoNumbers: The AutoNumber primary key will not reuse the ID numbers of deleted records. That is why the ID numbers for the new records are over 9000 when there are only 7537 records in the table. Quite a number of records were deleted along the way.

If there were going to be a lot of assignments that would not be given to all three classes, the query could be changed to include a parameter for the C/S field, which picks out the class and subject of the assignment. Wonder why I didn't do that?? Got smart just a bit too late!


Home > Jan's CompLit 101 > Working with Databases > Appendix

Last updated: September 17, 2012