You are on page 1of 7

Quick and Dirty MS Access Notes

Microsoft Access is a database management system. It is a piece of software that acts as a database. A
database is used to store information, display it in many formats, and answer questions about the data (for
example, How many widgets did we sell to people whose income was over $100,000 in the month of
February?). Such questions are called queries, and are a very important reason for using databases.
Before you can use queries on a database, you have to have data. Data in Access is stored in tables, which
are a lot like Sheets in Excel. <The largest part of the Access portion of Virtual Case 4 is getting data into
Tables in Access.>

Entering Data in Access


First, get into the Access Program itself. This task is done just like getting into Excel or Word: simply find
the icon (it is usually red and has a key on it) or name (Start / Programs / Microsoft Office / Microsoft
Access on many machines) and choose it. When Access (were currently using 2007) comes up, it looks
like this below:

Choose
New for
new file.
Give it a
name and
location.

In contrast to Excel and Word, Access does not start you out with a blank file, but rather you have to choose
Blank Database (as shown above) if you want to create a new file. Of course, if youre opening an
existing file, choose File / Open just like in Excel and Word.
If youre creating a new file, another difference between Excel and Word is that Access requests that you
name the file right away. Just go ahead and do that.
Ill name my new (currently blank) database VC4 (the extension automatically becomes .accdb, for
Access Database), click Create, and my screen now looks like this:

I can enter data


directly here,
much like in a
spreadsheet.

For entering data, were interested in the Tables Object, which comes up by default. Data entry is just
about as easy as on an Excel spreadsheet, so I just type data in and it is saved there. The Column Names
are called Fields in Access, and to change them from Add New Field simply double click on them. So,
in my sheet shown below, Ive done that for First, Last, and Addr1, names which I made up. I also
entered 3 rows, which in a database are called Records. Here the ID field is called the Primary Key,
which is a unique identifier for each record (row). I let Access auto increment this field, meaning it just
counts up in integers (regular numbers) each time I add a record.

Click on this to toggle


back and forth from
design view to
datasheet view.

Note that the Addr1 field in the Chuck Downing record does not completely show on the screen, but you
can resize the column width just like in Excel.
By clicking on the design triangle in the upper left as shown above, you can toggle back and forth between
datasheet view (what we started in) and design view. Design View is shown below:

The purpose of Design View is to allow you to change the data about the data. In other words, the design
tells the database what type (number, words, date, etc.) of data should be placed in that field, how long it can
be (55 characters, etc.), etc.
For VC4, you are provided with lots of information concerning the design of the tables (field names, data
types, description), as well as the data itself. I find it easier to import the data, and let Access guess at the
type. If it guesses correctly, my work is done. If it guesses incorrectly, I can correct it in design view.
So, I want to just take the data provided on the Web and import it into Access. To do that, due to the type of
data being provided (information on a Web page), we need to do three steps: 1) Copy/paste the data from
the Web page to Word, 2) Remove the Paragraph Marks if they have been inserted into the data (only in
the case of the Customer Table) , 3) Copy/paste the file from #2 to Excel, and 4) Save the Excel file and
choose the External Data tab at the top of Access and choose Excel as the file type. Then follow the
wizard (note that in the wizard you want to choose your own primary key- unique identifier of the record-,
as defined in the Case, and give a meaningful name to your new table).
Once done, check that the field names and data types match what is given to you in the case (has Text
been imported as Text, Currency as Currency, etc.). If not, correct them in Design View.
In the case of #2 from above, for the Customer Table, I need to first copy/paste into a blank document in
Word, select this entire new table, then choose Replace, and replace the paragraph marks (choose More /
Special / Paragraph Mark) with a single blank space (get your mouse cursor in the Replace With
section, and then hit the space key). Note: you need to choose Replace All so that all of the paragraph
marks are replaced with spaces. NOW I can copy/paste into Excel and proceed as above.
Finally, for the forms part of VC4, just go into the Create tab on the top of Access and choose More Forms
and then Form Wizard and follow the wizard. I usually choose All Fields and take the defaults, as
shown in class. You may want to go into the Design View of the Form and change some of the titles to be
more clear to your users.
When done with this, post the VC4 database file (.accdb extension DONT save as a web page) to
one group members www folder and register the URL.

Relationships
For your newly imported tables to talk to each other, they need to be tied together, or related. This is an
important distinguishing factor of Access vs. Excel. In Excel, the separate sheets do not talk to each other
by and large, making it hard to get complex answers to questions which involve more than one sheet.
Fortunately, relating tables in Access is easy, as long as the primary key in one table appears in another table
(called a Foreign Key in the other table). In our example, the Orders table contains both CustID and
ProdID, which are the primary keys in the Customer and Products tables. So, to form relationships simply
go to the Database Tools tab at the top of Access, choose Relationships, then add the tables you want to
relate or tie together. Once the table are on the screen, simply drag the matching keys from one to the
other, check the Enforce Referential Integrity box, and click Create, as shown below:

Doing so will produce relationship which appear like this:

Queries
One of the big reasons organizations enter data into Access is so that the managers can ask questions about
the data. For example, How many widgets did we sell to people from Minnesota in July? Such questions
are called queries.
To make a query, just go into the Create tab on the top of Access and choose Query Design. A box will
come up and you need to add the tables which will help you answer the query. Which table(s) contain data
that will answer the question? Pick those.
* To run a query at any time, click on the exclamation point at the top (Run). Also, you can toggle back
and forth between the query results (datasheet view) and design view just like you did with Tables.
You will now have a screen that looks something like this:

Now you need to select the fields needed to make your query. Move from left to right and pick the
appropriate fields after clicking on the arrow.
If there is a criteria (like only choose MN for state, or whatever), add that in the criteria row, as shown
below (so far, my query below is asking for the sales amount for purchases over the Internet):

Click on this to get the


new Totals row in
your query. This will
also allow count,
average, etc.

This query as written will list all Saleamt for all Internet orders. If we want the TOTAL of the Saleamt for
Internet orders, we need to click on the Sigma (Totals) as shown above. Then, we need to choose Sum
from the new Totals row as shown below:

Count can be done the same way, but after right-clicking on the column choose Count instead of Sum.
Of course, there are other possibilities as well.

To get unique values, right-click on the blank column just to the right of the last column youre using,
choose Properties, and then change Unique Values to Yes, as shown below:

You might also like