Microsoft Access V
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to Microsoft Access v. 1.2.1 September 2005 nikos dimitrakas Department of Computer Introduction to MS Access Stockholm and Systems Sciences v 1.2.1 September 2005 SU/KTH nikos dimitrakas Table of contents 1 Introduction............................................................................................................................ 4 1.1 Microsoft Access.......................................................................................................................... 4 1.2 Prerequisites ................................................................................................................................ 4 1.2.1 Literature .............................................................................................................................................. 4 1.3 Structure ...................................................................................................................................... 5 2 The case .................................................................................................................................. 5 3 Creating a database................................................................................................................ 8 3.1 Creating tables........................................................................................................................... 11 3.1.1 Design................................................................................................................................................. 11 3.1.2 DDL.................................................................................................................................................... 18 3.1.3 Defining other restrictions.................................................................................................................. 22 3.2 Working with relationships...................................................................................................... 26 3.2.1 Simple foreign keys............................................................................................................................ 29 3.2.2 ISA-inheritance................................................................................................................................... 31 3.2.3 Composite foreign keys...................................................................................................................... 35 3.2.4 Multiple relationships between the same two tables........................................................................... 36 3.2.5 Recursive relationships....................................................................................................................... 36 4 Querying a database............................................................................................................. 38 4.1 Preparing the database with data............................................................................................38 4.1.1 Through SQL...................................................................................................................................... 38 4.1.2 Through datasheets............................................................................................................................. 40 4.1.3 Through forms.................................................................................................................................... 43 4.2 Writing SQL .............................................................................................................................. 43 4.3 Reusing querys .......................................................................................................................... 45 5 Forms.................................................................................................................................... 48 5.1 Simple forms.............................................................................................................................. 48 5.2 Look-ups .................................................................................................................................... 59 5.3 Master-detail constructs ........................................................................................................... 75 5.4 Forms based on queries ............................................................................................................ 88 5.5 Non-data forms.......................................................................................................................... 93 6 Reports .................................................................................................................................. 95 6.1 Simple reports ........................................................................................................................... 95 6.2 Reports that combine many tables .......................................................................................... 98 6.3 Reports that are based on queries ......................................................................................... 103 6.4 Grouping and sorting.............................................................................................................. 104 6.5 Subreports ............................................................................................................................... 111 2 Department of Computer Introduction to MS Access Stockholm and Systems Sciences v 1.2.1 September 2005 SU/KTH nikos dimitrakas 7 Macros ................................................................................................................................ 117 8 Other useful tips ................................................................................................................. 123 8.1 Tip 1 - Look-ups for tables..................................................................................................... 123 8.2 Tip 2 - Viewing sub tables ...................................................................................................... 124 8.3 Tip 3 - Sorting and filtering ................................................................................................... 129 8.4 Tip 4 - SQL Parameters.......................................................................................................... 130 8.5 Tip 5 - Nesting SELECT statements...................................................................................... 130 8.6 Tip 6 - Application start-up.................................................................................................... 131 8.7 Tip 7 - Concatenating columns .............................................................................................. 131 8.8 Tip 8 - Using forms to find records........................................................................................ 132 8.9 Tip 9 - Keys and indexes......................................................................................................... 132 8.10 Tip 10 - Multiple sub forms.................................................................................................. 133 8.11 Tip 11 - Division in Access.................................................................................................... 134 8.12 Tip 12 - Object Dependencies............................................................................................... 135 8.13 Tip 13 - Copying objects between databases ...................................................................... 136 8.14 Tip 14 - Handling null........................................................................................................... 136 8.15 Tip 15 - Business rules .......................................................................................................... 137 8.16 Tip 16 - Set operators............................................................................................................ 138 8.17 Tip 17 - Multimedia .............................................................................................................. 138 8.18 Tip 18 - Compacting and repairing a database .................................................................. 145 8.19 Tip 19 - Linking external data ............................................................................................. 145 8.19.1 Creating an ODBC alias ................................................................................................................. 146 8.19.2 Linking DB2 tables from Access.................................................................................................... 149 8.19.3 Working with linked tables............................................................................................................. 153 8.20 Tip 20 - Working with dates and times ............................................................................... 155 9 Other resources................................................................................................................... 157 9.1 Web sites .................................................................................................................................. 157 9.2 Books ........................................................................................................................................ 157 10 Epilogue............................................................................................................................ 158 3 Department of Computer