DAY 22: ACCESS CHAPTERS 5,6,& 7 Naman Kohli November 5, 2013 UPCOMING DATES • Homework 5 – Friday November 8th by 11:55pm • Exam Review Session – Friday November 8th at 12pm • EXAM 2 – Access – 12th November at normal class time REPORT DESIGN • Did not cover design themes in reports last class. • The reports can have specific designs. DATA VALIDATION • Definition: A set of constraints or rules that help control how data is entered into a field. • Some data validation is done automatically – Access won’t allow you to enter text into a number field ESTABLISHING DATA VALIDATION • Establish REQUIRED fields. • Set DEFAULT VALUE for fields. • Set VALIDATION RULE and generate VALIDATION TEXT. • Use INPUT MASK wizard. • Look up Fields. ( already done in homework's ) ESTABLISH REQUIRED FIELDS • • • • • • The required fields must not be left blank. Lets try Open blank table in design view Field 1 -> Student ID : Number Field 2 -> Student Name : Text and in Properties set “REQUIRED” to “YES” Switch to data sheet view and try to enter a record with out giving Student Name, you will see an error SET DEFAULT VALUE FOR FIELDS. • • • • • Delete the records first Switch to design view: Field 3 -> Score : Number Set DEFAULT VALUE property to 30 Observe records. SET VALIDATION RULE AND GENERATE VALIDATION TEXT. • Validation rule is designed to restrict the data values that can be entered into a field. • Validation text informs users that the validation rule has been broken, and how to correct it. • Lets try : Set validation rule and text for SCORE FIELD • Delete all the records first and remove the default value set. • Validation rule: [Score] <= 60 • Validation Text: You can’t enter a value greater than 60. Please enter correct value. • Now try to enter 90 in Score field for a record and observe the warning message. SQL • Stands for Structured Query Language • Pronounced as "sequel” • Specially created programming language used to manage data in a relational database management system • Whether or not you realize it, you’ve been using SQL in Access all along! WHAT WE SEE WHAT ACCESS SEES THE RESULT WHY IS THIS USEFUL? • On exams, and homework 5, SQL code will be given and you need to copy and paste it into Access! • (We will do this as part of an In-Class Example) • You could, in theory, write these SQL statements from scratch… but that would be another course entirely. IN-CLASS EXAMPLE - SQL IMPORTING DATA FROM EXCEL • a. Open Access. In the File tab, click Save Database As, and then type LastName_FirstName_Import. Click Save. • b. Click the External Data tab, and click Excel in the Import & Link group to launch the Get External Data - Excel Spreadsheet feature. Select the Import the source data into a new table in the current database option. • c. Click Browse, and select the Data File. Click Open, and then click OK to open the Import Spreadsheet Wizard. The top of the first window shows all of the worksheets in the workbook. This particular workbook contains only two worksheets: Customers and Accounts. The Customers worksheet is active, and a list of the data contained in the Customers worksheet displays in the Wizard. • e. Click Accounts, and then click Next. • f. Ensure that the First Row Contains Column Headings check box is checked to tell Access that column headings exist in the Excel file. The field names, AID, CID, BID, and Balance, will import from Excel along with the data stored in the rows in the worksheet. The field names will be modified later in Access. • g. Click Next. The AID (AccountID) will become the primary key in this table. It needs to be a uniqueidentifier, so we must change the properties to no duplicates. • h. Ensure that AID is displayed in the Field Name box in Field Options. Then click the Indexed arrow, and then select Yes (No Duplicates). Click Next. • i. Click the Choose my own primary key option. Make sure that the AID field is selected. Click Next. The final screen of the Import Spreadsheet Wizard asks you to name your table. The name of the Excel worksheet was Accounts, and Access defaults to the worksheet name. • j. Click Finish to accept the Accounts table name. A dialog box opens asking if you wish to save the steps of this import to use again. If this were sales data that was collected in Excel and updated to the database on a weekly basis, saving the import steps would save time. You do not need to save this example. • k. Click the Close button. The new table displays in the Navigation Pane and resides in the Bank database. • l. Close the table. HOMEWORK 5 HINTS HOMEWORK 5 HINTS • Query 6E – States, FraudRankings and Fraud Types Table – Rank equal to 1 – Have to include rank (may not be immediately visible to some) HOMEWORK 5 HINTS • Query 6G – FraudRankings and Fraud Types Table – Rank equal to 1 – Use totals to count state abbreviation ANALYSIS QUESTIONS • If you run out of room to type responses, change the field data-type to memo. EXAM 2 GENERAL HINTS FOR ACCESS EXAM • Read the instructions all of the way through – Things that future steps ask you to do may give you a hint how to complete earlier steps GENERAL HINTS • Examine given tables for good ideas of what to name your fields Another good reason to read the whole assignment first! GENERAL HINTS • Examine given tables to understand what the formatting should look like GENERAL HINTS FOR ACCESS EXAM • Close tables as you are done with them. – Remember, that Access is designed so multiple people can work on a database at once – This means that an open table is “locked” and nothing that references it can have changes made to it GENERAL HINTS FOR ACCESS EXAM • The MOST IMPORTANT THING you can do is be positive your tables are correctly designed – Improper table design will render your database unusable. – End of story.