LSP 121 Access Forms, Reports, and Switchboard
Overview You’ve learned several of the basic nuts-and-bolts of creating a database, entering data, and querying it. Most people who interact with databases on a daily basis never get to this level. We need to give people a way to enter information into a database and get information out of a database (query) without having to go into the level of detail that we’ve learned in this course. Today we will learn how to do two things that will make it very easy for the average user to interact with a database: – Enter information using a ‘Form’ – Retrieve information using a ‘Report’
Access Forms
A graphical database such as Access allows you to – View records – Create new records – Modify existing records using “Forms”. Here is a view of one of the records from the Listings table in our Real Estate database. We will create this form together today.
Displaying Data – The Form One way to start a form is to use the Form Wizard – Create Forms More Forms Form Wizard – Let’s create a form for our Real Estate database, for the Listings table (we’ll do a little bit of today’s activity but not all of it)
Forms Continued Now go back into Design View to edit the form Resize windows Move fields around Many more properties / controls available
Toolbox of Basic Controls Checkbox controls – displays a check box; useful for Yes/No fields Label controls – headings, labels, captions, instructions Text Box controls – data is displayed or entered here Toggle buttons, option / radio buttons, check boxes Option group – contains multiple toggle buttons List box – a pull down menu which is always down Combo box – a pull down menu which you must pull down, and also lets you add an option that is not on the list When working with forms, notice Table button (or Field List), Toolbox button, and Wizard button in Toolbox
Label Checkbox Textfield Subform List / Combo boxes Some examples of CONTROLS Navigate between records
Form practice,contd Let’s try another example - WE MAY LEAVE THIS OUT IN SUMMER Suppose you had a table containing information used to record people who wish to obtain a bank loan such as a mortgage. Create a table called ‘LoanApplicant’ with fields for ApplicantID (autoNumber, primary key), FullName (text), Married (yes/no), Employed (yes/no), HomeOwner (yes/no), City (text), State (text), – Go ahead and place this table in your RealEstate database for now even though it’s not really related to real estate. Now create a form from this table. For each field though, apply the following “properties” to each object (name, married, etc). To modify an object’s properties, click on Design Tools Property Sheet. In that sheet, you can use the select box to choose the field you wish to modify. – Name text 50, Married Yes/No, Employed Yes/No, Home Owner Yes/No, City text 50, and State text 2 Make Name a text box, Married a toggle button, Employed a check box, Home Owner an option button, City a combo box, and State a list box – You can create this form within your Real Estate database even though there is no corresponding table. In the real world, though, forms are typically intended to work with a table that has already been created.
Sample Form Click on Add Existing Fields button. If you can’t click on this, click on Properties and set Record Source to appropriate table Make sure Use Control Wizards button is pressed Click on ab| (Text Box), then click and drag on Name field Click on Toggle Button, then click and drag on Married field Now put a caption or a picture in the toggle button using Properties
Properties Pretty much everything in Access has a list of properties associated with it To display properties, you can click on View Properties from the menu bar Or you can right click on an item Let’s look at some properties
Creating a Form Using Multiple Tables Create form for main table On toolbox, click on subform button (make sure the Wizard button is pressed) Answer the wizard’s questions
*** Forms Continued Note – if you change the data on the form, you are changing it in the database! You can use the form for entering new data You can even create a form for a query. However, if you enter new data on the query form, it changes the data in the table! Let’s stop here and try our activity
REPORTS Reports are yet another way to view the information from a database. However, the operative word here is ‘view’. That is, reports are meant to be viewed/printed. They are not used for searching, entering, or editing information. Because reports are meant to be viewed, Access gives you many options for layout and design.
Parts of a Report A report has the following parts: – Report header (one per report) – Page header (one per page) – Detail (line(s) of information) e.g. summary of each customer – Page footer (one per page) – Report footer (one per report)
ABC Monthly Report (page header) EmployeeIDExpenseJob Title Jones123$134.40Engineer(detail section) Smith234$333.22Programmer Zygote345$123.33Analyst April 19, 2007 (page footer) An Access Report
Creating a Report Use the Wizard to create a report Here are the first questions:
Creating a Report Do you want to group items in your report? For example, do you want to group by job title?
Creating a Report Or maybe you want to group them by city?
Creating a Report For the remaining fields, do you want them in any particular order?
Creating a Report Finally, do you want a total of all salaries? Click on Summary Options and get this:
Creating a Report What kind of report layout would you like?
Creating a Report Finally, you may have to go into Design View to “clean up” the report
Let’s Try an Example Using the Real Estate database, create a report which uses the fields from the Listings table and includes the Listing Number, Address, City, Frame Type and Taxes. Group by City Total and Average the Taxes (in the ‘Sort Order’ wizard window, click on ‘Summary Information’) Important: If the area assigned to the design is not large enough to display the full value (e.g. if the area to display taxes is small), all you will see are number signs (e.g ####). In this case, you need to go to the ‘Design View’, single-click the appropriate box, and drag the right margin to make it wider. You may encounter this when displaying the taxes in our example.
The Switchboard (optional)
The Switchboard The Switchboard pulls it all together After defining and populating the database, creating the forms and reports, you can roll it all into one nice package to give to your client (user)
Creating a Switchboard
Then click on the Yes button
Creating a Switchboard Then click on Edit
Creating a Switchboard To add buttons to the Switchboard, click on New
Creating a Switchboard Then enter the name you want to appear on the Switchboard, what the Switchboard operation is, and where the form/report/query is coming from Let’s try an example
Creating a Switchboard How do you make it so the switchboard is the first thing to open when a user runs Access? – Click on the Office button in upper-left corner – Click on Access Options in bottom right of this smaller window – Click on Current Database on left margin – Under the Display Form option, select Switchboard from the drop-down list – Now when someone opens this database, the switchboard will automatically pop up