12.07.2015 Views

Microsoft Access Tutorial B - Cengage Learning

Microsoft Access Tutorial B - Cengage Learning

Microsoft Access Tutorial B - Cengage Learning

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• Spell, capitalize, and space a field’s name exactly as you did in the table definition. Ifthe table definition differs from what you type, <strong>Access</strong> thinks you’re defining a newfield by that name. <strong>Access</strong> then prompts you to enter values for the new field, which itcalls a “Parameter Query” field. This is easy to debug because of the tag ParameterQuery. If <strong>Access</strong> asks you to enter values for a Parameter, you almost certainly havemisspelled a field name in an expression in a calculated field or a criterion.Example: Here are some errors you might make for Wage Rate:Misspelling: (Wag Rate)Case change: (wage Rate / WAGE RATE)Spacing change: (WageRate / Wage Rate)• Don’t use parentheses or curly braces instead of the square brackets. Also, don’t putparentheses inside square brackets. You are allowed to use parentheses outside thesquare brackets, in the normal algebraic manner.Example: Suppose that you want to multiply Hours times Wage Rate, to get a fieldcalled Wages Owed. This is the correct expression:Wages Owed: [Wage Rate]*[Hours]This would also be correct:Wages Owed: ([Wage Rate]*[Hours])But it would not be correct to leave out the inside brackets, which is a common error:Wages Owed: [Wage Rate*Hours]“Relating” Two (or More) Tables by the Join OperationOften, the data you need for a query is in more than one table. To complete the query, youmust join the tables. One rule of thumb is that joins are made on fields that have commonvalues, and those fields can often be key fields. The names of the join fields are irrelevant—the names may be the same, but that is not a requirement for an effective join.Make a join by first bringing in (Adding) the tables needed. Next, decide which fieldsyou will join. Then, click one field name and hold down the left mouse button while draggingthe cursor over to the other field’s name in its window. Release the button. <strong>Access</strong> puts in aline, signifying the join. (Note: If there are two fields in the tables with the same name,<strong>Access</strong> will put in the line automatically, so you do not have to do the click-and-drag operation.)You can join more than two tables together. The common fields need not be the same inall tables; that is, you can “daisy-chain” them together.A common join error is to Add a table to the query and then fail to link it to anothertable. You have a table just “floating” in the top part of the QBE screen! When you run thequery, your output will show the same records over and over. This error is unmistakablebecause there is so much redundant output. The rules are: (1) add only the tables you needand (2) link all tables.Next, you’ll work through an example of a query needing a join.AT THE KEYBOARDSuppose that you want to see the last names, SSNs, wage rates, salary status, and citizenshiponly for U.S. citizens and hourly workers. The data is spread across two tables, EMPLOYEEand WAGE DATA, so both tables are added, and five fields are pulled down. Criteria are thenadded. Set up your work to resemble that shown in Figure B-15.20 <strong>Tutorial</strong> B

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!