Beruflich Dokumente
Kultur Dokumente
Microsoft Access is a Relational Database Management System (RDBMS), designed primarily for home or small business usage. Access is known as a desktop database system because it's functions are intended to be run from a single computer. This is in contrast to a server database application (such as SQL Server), where it is intended to be installed on a server, then accessed remotely from multiple client machines. Microsoft (or MS) Access is a software package that you install just like any other software package, and is bundled as part of the Microsoft Office suite.
If you already have Access open, you can go to the "File" menu and click on "New Database":
2. Choose "Blank Database". (Skip this step if you already chose "Blank Database" at step one). You also have the ability to choose from a template, but we'll just use a blank database here:
Once you've completed the above tasks, you should see a blank database, like this:
We know this database is blank because it doesn't have any tables. If it did, you would see these tables in the middle pane of the table tab. Now that we have our blank database, we can start adding some tables.
Design View
"Design View" enables you to create your database tables and specify the columns and their data types etc. The following steps demonstrate how to switch to Design View and create a table.
1. Ensuring you have your blank database open and you're on the following screen (with the "Tables" tab selected), click "New":
3. Fill out the details in the "Field Name" column and the "Data Type" column. Here, we are creating the column names and specifying the type of data that can be entered into them. Restricting the data type for each column is very important and helps maintain data integrity. For example, it can prevent us from accidentally entering an email address into a field for storing the current date.
Other options for each column include restricting the length of data (under "Field Size"), setting a default value (this is used if someone leaves the field blank), specifying whether the data is required, and more. Leave these options with their default value for now.
4. Click the "Save" icon, enter the table name ("Individual"), and click "OK":
5. When prompted to set a primary key, click "Yes". (A primary key ensures that the data in this column is unique - no two values can be the same. This is important for when you need to select or reference data from this column):
Datasheet View
You have now created a database table called "Individual". You can now switch between "Design View" and "Datasheet View" as you wish. Datasheet View allows you to see any data that has been entered into the table.
1. From the "View" dropdown icon, click "Datasheet View" (this changes the view from Design View, to Datasheet View):
We have just created a database table. This table doesn't have any data yet, but we have created the columns that are required before any data is entered.
Direct entry
You can type directly into the table while it's in Data Sheet view. Initially, this may seem like the quickest and easiest method, but it's not suitable if you have lots of data, and/or if non-technical users need to enter data.
Form
You can set up a form, so that non-technical users can enter data into the form. Once they submit the form, the data is automatically inserted into our table. The form could insert data into multiple tables too - saving you from having to open up each table to manually insert the data. Access provides a form wizard, which steps you through the process to building a form. We'll cover this in the next lesson.
3. Select the fields that you need on your form and click "Next". In this case, we only need the user to enter first name and last name, so we choose those two fields:
4. Choose which layout you'd like your form to use. Leave this at the default ("Columnar") and click "Next":
5. Choose which style you'd like your form to use. Leave this at the default ("Clouds") and click "Next":
This is a very basic form and in most cases, you'd have a lot more fields on your form. You can see that the form is already presenting the first record in our Individual table.
To jump to the next record, click the button. To jump to the last record, click the button. To jump past the last record so that it's blank and ready for a new record to be entered, click the button.
Adding a Field
Let's say we want to add the IndividualId field to the form. To do this:
2. You should now see a "Field List" panel. From this panel, click and drag the field you want onto the form area. When you release your mouse, the field will be added to the form:
Properties
For any element that you select, you can view/change its properties. To view the properties panel, select "Properties" from the "View" menu. The following screenshot shows that we are viewing the properties for the IndividualId text box. The "Data" tab is selected, which shows us the source of the data to populate the text box. The "Formatting" tab enables us to change the way the field is displayed.
3. Choose the fields you'd like to be presented in the results of your query. To choose 1 field at a time, select it and click the ">" arrow. To choose all fields click the ">>" arrows. For now, just select the "FirstName" and "LastName" fields, then click "Next":
The Result
You should now see something like this:
At this stage, you may be thinking that there's not much difference between the results of our query and our table. We can still see all records from our table. The only difference is that we can only see 2 fields instead of all 4 fields.
Well if that's what you're thinking, you'd be right! In our next lesson, we're going to modify our query so that we can only see some of the results.
The top panel shows us the tables that are used in this query (we only use one table in our query). The bottom panel is where we specify what to do with each field in the table. We can nominate to display a field or not display it. We can sort the results by any of these fields. We can also provide criteria to be used in filtering the results. We'll do this in the next step. 2. In the "Criteria" cell for the "FirstName", add the word "Homer". While you're there, add the IndividualId field so that it will also be displayed in our results. Do this by selecting "IndividualId" from the dropdown menu on the third column. Also, ensure that the "Show" checkbox is
checked:
The Result
Now when you switch back to Datasheet View, you should now see something like this:
So you can see that, once we get a lot more data into our database, queries can be very useful. Imagine if there were 100 individuals in our database called "Homer". You could also add criteria into the "Or" field. For example, you might want to search for individuals called either "Homer" or "Barney".
You may need to practice this to get a good understanding of what it can do. Switch back and forth between Design View and Datasheet View as many times as you like. Change the criteria, add some fields, show fields, don't show them... Once you become familiar with queries, you'll realise the true benefits of database management systems.
2. Use the dropdown menu to select your first action - choose "OpenForm". In the bottom pane, select the form name you wish to open - choose "Individual Form"
3. Use the dropdown menu to select your second action - choose "GoToRecord". In the bottom pane, choose the record you want to go to - choose "New". What we're doing here is ensuring that the form doesn't open up a previous record - it goes straight to the end and has a blank record ready for you to enter a new record (this saves time and unnecessary clicks).
4. You're now ready to save your macro. To do this, click on the "Save" icon and enter a name for your macro. Make sure you name this macro "Autoexec". By naming it Autoexec, we are instructing Access to run this macro everytime we open the database.
4. Choose a location for your Excel spreadsheet (or double click on an existing one) You now have an Excel spreadsheet containing the data from your query that you can email to anyone you like.
MS Access
Access is more suited for desktop use with a small number of users accessing it simultaneously. One reason you might choose to use Access over SQL Server is for compatibility/sharing. You might need to email someone a copy of your database. People are more likely to have Access on their desktop computer than SQL Server. You'll generally only find SQL Server on developers' computers/servers or on production server machines. Another reason you might use Access instead of SQL Server is money. You might already have installed Access as part of the Microsoft Office suite. Purchasing SQL Server would be an extra expense that may not be necessary - depending on your situation. SQL Server can also be quite expensive.
MS SQL Server
SQL Server is a more robust database management system. SQL Server was designed to have many hundreds, or even thousands of users accessing it at any point in time. Microsoft Access on the other hand, doesn't handle this type of load very well. This makes SQL Server perfectly suited for database driven websites. You should never use Access for a database driven website - unless it has a very small amount of traffic (like you and a few of your friends). Even then, you may find yourself getting errors due to multiple users trying to access the database at the same time. SQL Server also contains some advanced database administration tools that enable organisations to schedule tasks, receive alerts, optimize databases, configure security accounts/roles, transfer data between other disparate sources, and much more.
What Next?
If you are familiar with relational database design, you will be able to use your knowledge of Access to store data across multiple tables. You can then create queries across multiple tables. One area we didn't cover in this tutorial is reporting. If you need to print out reports from Microsoft Access, you can use the "Report Wizard" tab to do this (via the "Reports" tab). You will probably find this just as intuitive as creating a form or query. As with forms and queries, you can use Design View to adjust your report. Also, you may have noticed when switching between Design View and Datasheet view that there's another option - "SQL View". SQL stands for Structured Query Language and is another method of creating tables, queries, and other database objects. If you're interested in learning more about SQL, check out the SQL tutorial. This will give also you a better understanding of what Microsoft Access is doing behind the scenes.