BarCharts, Inc.®
WORLD’S #1 QUICK REFERENCE SOFTWARE GUIDE
Ta b l e s a n d Q u e r i e s Contents Pg. 1 Main Window, New Features, Getting Help Pg. 2 Standard Toolbar Icons, Terminology, Database Objects, Database Toolbar Icons Pg. 3 Creating a Database, Creating Tables, Table Design Toolbar Icons, Table Design View, Data Types
Pg. 4 Common Field Properties, Primary Keys, Creating Queries, Design View Pg. 5 Query Design Toolbar Icons, Query Design, Adding/Removing Tables, Relating Tables, Adding Fields to the QBE Grid, Specifying Criteria Pg. 6 Viewing the SQL Code, Table & Query Datasheet Toolbar Icons, Record Navigation Icons, Common Keyboard Shortcuts, Viewing Object Dependencies
Main Window 1. Title Bar. Includes the name of the
2. 3.
4.
5.
6.
1
database (in this case expenses) and the 2 database format (in this case 2002-2003). 3 Menu Bar. Available menus are displayed 4 in this area. Toolbars. Each customizable toolbar provides fast access to many Access® features and functions. Database Toolbar. The tools available in 5 the Database window are displayed here; they vary depending on the object type selected. Common tools include design mode, new database object, delete, view by large icon, view by small icons, view as list and view details. Objects Bar. When a database is open, the 6 Objects Bar is displayed in this area of the window. It provides quick access to the tables, queries, forms, pages, macros and modules defined within a database. To access the objects of a desired type, click the object type name and the items available are displayed in the right pane of the window (see also Objects). Status Bar. Displays the current status of Access 2003®. In the main
8
7
Microsoft®
Database window, the status will typically be “Ready”; instructions and other information may appear in this area in other views. 7. Objects. The objects of a selected type in a database are displayed in this pane. To display (open) an object, double-click the item. 8. Ask a Question. Provides quick and easy access to the Help system.
New Features in Access® 2003 Access 2003® offers many new features over Access XP®. Some of the new and improved features are (those included in the guide are in red): • Information is now available on the dependencies between database objects, reducing maintenance costs and errors. In addition to viewing the list of objects bound to a selected object, you can also view the objects used by the selected object. Note, however, that macros, modules and data access pages are not searched for dependencies. • You can turn on automatic error checking; this feature points out errors, such as two controls using the same keyboard shortcut, or the width of a report exceeding that of the page it will be printed on. • Smart Tags, introduced on some products in Office XP®, can now be added to tables, queries, forms and reports, among other objects. • When you modify an inherited field property (in Table design view), Access 2003® displays a Smart Tag with an option to update the property of all or some controls bound to the field. • If a theme (except the default) has been chosen in Windows XP®, it will, if desired, be applied to views, dialog boxes and controls. • Sorting behavior has been standardized; not only can either ascending or
• • •
• • • •
descending sort order of up to four fields be specified in the Report wizard (as in past versions), but also in the List Box and Combo Box wizards (used with forms) and the Lookup wizard (used in table definitions). You have more control over the AutoCorrect feature. In the SQL and query design views, the text font and font size can now be changed. In the SQL view of a query, help specific to Jet SQL keywords, VBA functions and Access® functions is available by pressing F1 to bring up the help that corresponds to the text nearest the cursor. A local copy of the structure or data and structure contained in a linked table can be created. XML support has been added, allowing data to be more easily exchanged with many different data sources. New task panes include: Getting Started, Help, Search Results and Research. The Research task pane offers a wide variety of reference information at your fingertips (as long as you have an Internet connection). Available tools include: encyclopedia, dictionary, thesaurus, on line language translation, stock (and other company) information and Web search. Third parties can also add their own content that integrates seamlessly.
Getting Help Access 2003® offers an extensive help system that can be displayed by clicking the
help window for that topic will be displayed. Tip: If there is an active Internet connection, the default is to search Microsoft Office Online®; in many cases the help that comes with Access® is at least as useful. To search other help locations, click the down arrow near the bottom of the page and select the desired help (especially useful is Offline Help) then click the Start Searching button .
icon on the Standard Toolbar.
To use the Ask a Question feature: 1. Enter
the
question
in
the
Type
a
question
for
help
field
(on the right side of the menu bar) and press Enter. 2. In the Search Results task pane, click the link for the desired article and the 1
Standard Toolbar Icons
Access® 2003 Terminology
Icons that vary from view to view will be described in their respective sections
• database. A collection of related objects designed to be used together (ex.: inventory management, scheduling, managing a list of recipes, etc.). Basically, it is composed of tables (which are made of fields [columns] and records [rows]) in which information can be stored and organized. Once the information is entered into a database, it can be analyzed, printed, sorted and retrieved. Access 2003® is a software application that assists in the creation and maintenance of databases. • drop down menu. A menu of choices appearing in dialog boxes and next to
elsewhere in this chart. These are the icons available in most Access® views: Design View. Allows viewing or editing of the structure of the table or query in a graphical format. See also SQL view. Datasheet View. Used to enter or view data in a table or query. PivotTable View. Opens a PivotTable designer, similar to that in Excel®, to view data in different ways; fields and records can be defined, as can filters
some icons; accessed by clicking the downward facing triangle . • foreign key. A field in a table that references an indexed field (usually the primary key) of another table. • primary key. A field that uniquely identifies each record; often numbers, such as social security numbers, UPC codes, etc. No two records in the same table can have the same primary key. • relational database. Lets you define relationships between information contained in multiple tables; allows for extensive information manipulation and results in both smaller databases and fewer data entry errors (due to decreased duplication of information). Access 2003® is a relational database application. • relationship. Link between 2 tables (ex. a table with item numbers and descriptions and a table with sales of those items). • ScreenTip. Text that appears when an icon, button, etc. is pointed at, but not clicked. Here, the text “Italic.” • toolbar. Located under the Menu Bar, it provides quick access to common features of the application.
and summary information. PivotChart View. Opens a PivotChart designer; similar to Excel® charting capabilities. Data can be added, graphed and/or filtered as desired. SQL View. Displays the SQL-standard code created by graphical actions; code can be edited to provide access to features unavailable in the GUI. Unlike the other view options, only available for queries. Save. Saves the displayed object when not in Datasheet view. Data is automatically saved when leaving a record. File Search. Allows searching for files that meet specified conditions (ex. containing a certain phrase) in specified locations and of specified types. Print. Prints the current object (all of the records) to the printer used last (or the default if one hasn’t been used). The printer will be displayed in parenthesis in the ScreenTip. Not available in Design or SQL views.
Database Objects
Print Preview. Displays how the current object will look on screen when printed. Not available in Design or SQL views.
Databases are made up of objects illustrated in the Main Window, item 7.
Spelling. Opens the spelling checker. Only available in Datasheet view.
Table. Stores data in a table in rows and columns very similar to a spreadsheet. All other objects directly or indirectly access the data stored in them.
Cut. Removes the selected text or record(s) from the table (in Datasheet view) or removes the criteria or field(s) from the table or query (in Design
Query. Locates and displays information (from tables and/or other queries) based on user-defined criteria.
view) and places it/them on the clipboard for pasting. Copy. Copies the selected text or record(s) from the table (in Datasheet
Form. Allows information from a table or query to be displayed in a userdefined format.
view) or copies the criteria or field(s) from the table or query (in Design view) and places it/them on the clipboard for pasting.
Report. Compiles, displays and prints information located in tables and/or queries.
Paste. Places the contents of the clipboard into the current field or record (in
Macro. Simple way to automate many tasks; can be used with forms, reports and modules.
Datasheet view) or places the criteria or field in the table or query definition (in Design view). Pasted records are added to the end of the table.
Module. Provides access to complex and powerful programming abilities; for more information on Visual Basic see our QuickStudy ® Visual Basic guide.
Undo. Reverses the last action (typing, formatting, deletion, etc.) taken. Remembers the last 99 actions. Multiple items can be undone in order by
Database Toolbar Icons
repeated clicking. Be careful: Multiple changes can be undone with a
The Database Toolbar is automatically displayed when a database is opened as illustrated in the Main Window, item 4. Open. Opens the selected Table or Query object in datasheet view, allowing data to be viewed and usually edited. Design. Opens the selected Table or Query object in Design view, where it may be viewed and/or modified. New. Opens a dialog box prompting for the method to be used to create the new Table (Design or Datasheet view or the Table, Import Table, or Link Table wizard) or Query (Design view or Simple Query, Crosstab Query, Find Duplicates Query, or Find Unmatched Query wizard) object. Delete. Deletes the selected Table or Query object. Large Icons. Displays the objects and icons in the Objects Bar using large icons. Small Icons. Displays the objects and the icons in the Objects Bar using small icons in multiple columns. List. Displays the objects and the icons in the Objects Bar using small icons in a single column. Details. Displays the objects and the icons in the Objects Bar using small icons in a single column (like List view) with the following added information: description, date & time of last modification, date & time of creation and type of object (for queries, the specific type of query is listed, such as Select, Make-Table, Update, Append, or Delete). This is the view illustrated on Page 1.
single click when a record is undone. The standard drop down of Undo actions is only available in Design view. Redo. Undoes the last undo. Remembers the last 99 Undo actions. Multiple items can be redone in order by selecting them from the drop down menu (only in Design view). Not available in Datasheet view. Database Window. Displays the main database window (illustrated on the front cover) where any object type may be created, renamed, deleted, opened, etc. New Object. Creates a new object, including query, table, form, or report. The button will vary depending on which type of new object is the default (this is AutoForm). The AutoForm and AutoReport features will build a form or report (respectively) based on the current table. All other choices create a new, empty object of the type selected. Microsoft Office Access® Help. Opens Microsoft Office Access® Help. Properties. When a table is open, its properties are displayed (such as default view, filter and order by). For queries, if a field is selected, its properties are displayed; otherwise, overall query properties are displayed. Build. Opens the expression builder (to aid in building formulas used in setting default values and validation expressions), the Input Mask wizard, etc. Helps with more complex field or criteria properties. 2
Creating a Database
Table Design Toolbar: Unique Icons
• Access 2003 (like all previous versions of Access ) creates a database file on the disk as soon as the database is created. • When the application is started, the Getting Started Task Pane is displayed, allowing the creation of both blank and wizard-assisted databases. This task pane allows recently accessed databases to be opened quickly, a link to open the New File Task Pane and the ability to access Office Online®.
Common icons used in Table Design view (in addition to the standard icons already described):
®
®
Primary Key. Sets the primary key to the selected field(s). Indexes. Opens a dialog box where indexes can be created and modified, including sort order, making the index the primary key, forcing all records in the field to be unique and ignoring (in the index) NULL (blank) values. Insert Rows. Inserts a new row for a new field below the selected field.
New File Task Pane
Delete Rows. Deletes the selected field(s).
• Provides templates (either installed with Access®, or from the Office Online ® site) that assist with creating a blank database, a database based on an existing database or a database with necessary tables, queries, forms and reports for a given predefined scenario.
Table Design View • Use to create a new field, give it a name and select the appropriate data type. • Optionally, a description may be entered for the field to describe its purpose, its role in relationships with other tables, expected data, etc.
Creating a table in Design view. 1. In the main database window, click the Create table in Design view link. 2. Enter a name for each field (up to 64 characters), select a data type for each field and optionally enter a description for each field. To set other properties, see Common Field Properties (pg 4).
Creating a blank database. 1. In the New File Task Pane, select Blank Database under the New heading. 2. Select the desired file location and name and click the Create button. 3. The main database window is displayed. Follow the instructions in this guide to create any necessary tables and queries.
3. When finished, click the Save button Datasheet View button
Editing a table’s design. 1. In the main database window, select the desired table, then click the Design button 2. Make all desired modifications. Microsoft®
3. When finished, click the Save button Datasheet View button
Using Wizards to Create a Database • Many predefined databases come with Access®; others are available on the Microsoft Office Online® Web site. • Plain templates use the Access® templates icon
to save it and remain in Design view or the
to save it and begin entering data.
, while wizards use
the wizards icon . Using the Wizard 1. Click the On my computer link in the Templates section of the New File Task Pane and the Templates dialog box will open. 2. Select the Databases tab. 3. Select the desired purpose for the database from the list and click OK. 4. Modify the design of the tables and queries as described in this guide.
Creating Tables • Proper table design is beyond the scope of this chart, but the mechanics of how to do so are described here.
Using Wizards to Create a Table 1. In the main database window, double click Create table by using wizard. 2. The Table wizard will appear. Select either the Business or Personal radio button. 3. Select the desired table from the list and a list of suggested fields will appear in the middle (Sample Fields) pane. Select the desired fields and click the Select Item button to add them to the Fields in my new table pane. 4. Optionally: Select a field in the Fields in my new table pane and click the Rename Field button to select a different name. Rename the field and click OK. 5. Click the Next button. 6. Enter the name for the new table in the What do you want to name your table? field. 7. To have Access® select the field to uniquely identify each row, select the Yes, set a primary key for me radio button; to manually set the primary key, choose the No, I’ll set the primary key radio button. 8. Click the Next button. 9. If No, I’ll set the primary key was selected, select the key and type of data (consecutive numbers assigned by Access®, numbers manually entered with data, or text and/or numbers entered with data) and click Next. 10. If the wizard detects (based on field names) a relationship to another table, it will be listed here; other relationships can be manually configured as well. To configure the relationship, click the Relationships button and select how they are related. When finished, click Next. 11. To further modify the table’s design, click Modify the table design, otherwise select either Enter data directly into the table or Enter data into the table using a form the wizard creates for me and click Finish.
.
to save it and remain in Design view or the
to save it and enter or edit data.
Data Types Data Type
Subtype (if any)
Purpose
Text and numbers not used in calculations, such as names, phone numbers and zip codes. 1-255 characters. Memo Variable length text and numbers, such as notes about a customer. Up to 65,535 characters. Number Byte Whole numbers from 0-255. Used for small values, such as number purchased or as a key for small sets of data, such as days of the week. Integer –32,768 to +32,767 with 0 digits to the right of the decimal. Long Numbers from –2,147,483,648 to + 2,147,483,647 with 0 digits Integer to the right of the decimal. Commonly used when linking fields. Single Numbers from –3.40282338 to –1.401298–45 for negative numbers and from +1.401298–45 to +3.40282338 for positive numbers with 7 digits of precision to the right of the decimal in scientific notation. Double Numbers from –1.79769313486231308 to –4.94065645841247–324 for negative numbers and from +4.94065645841247–324 to +1.79769313486231308 for positive numbers with 7 digits of precision to the right of the decimal in scientific notation. Decimal Stores numbers from –1028 to +1028 with up to 28 digits to the right of the decimal. Date/Time Dates (from 100-9999 A.D.) and times. Currency Used for financial and other mathematical calculations with 1-4 digits after the decimal point. Faster than single or double data types if 1-4 decimal places needed as fixed-point math used instead of floating point math. Accurate to 15 digits to the left of the decimal and 4 after it. AutoNumber Unique, usually sequential, number, typically incremented by 1 for each new record. Used often in relationships between tables. Yes/No Simplest data type; can contain only yes or no, true or false, on or off, or checked or unchecked data. OLE Data linked from another application (up to 1 GB in size), Object such as a picture, Word® document, etc. Hyperlink Link to a URL (on the Internet, for example) or a UNC path (location on the network). Lookup Creates a combo (drop down) menu used to select data from another Wizard table. Typically, text data (such as customer names) is displayed in the list, but the underlying primary key for the record (ex. a customer ID) Text
is stored in this table, not the longer textual form. Tip: When choosing a number type, use the simplest type that will meet the requirements. They can be processed faster in calculations and don’t take as much storage space in the database. The number formats are listed in the table above from simplest/smallest to most complex/largest. 3
Common Field Properties Property
Purpose
Caption
Used as the field (column) heading in Datasheet view for queries and tables, and as the label for a field on a form. Left blank, it is the field name. The number of digits that will be displayed to the right of the decimal point. Caution: The actual value will be used in all calculations involving the field, not the number of digits displayed. The value automatically placed in the field for all new (but not existing) records. For example, the current date, a common title or an area code. For text, the maximum number of characters allowed; for numbers, the number type (byte, integer, etc.). For text, force to upper or lower case, require a minimum number of characters, etc. For numbers, the display of the numbers (scientific notation, currency, percent, etc.). For date/time, the format of the date and/or time (formats are defined in the Regional Settings control panel). For yes/no, whether to display yes/no, true/false, or on/off. For numbers and date/time, custom formats can be defined. An index makes data retrieval and relationships to other tables faster and more efficient. Creating too many indexes generally decreases performance. Three settings are available: No [no index for the field; the default], Yes (Duplicates OK) [the field is indexed, but there may be more than 1 record with the same value, such as for a last name] and Yes (No Duplicates) [the field is indexed; no 2 records can have the same value in the field, such as employee ID number or Social Security number]. The primary key is always Yes (No Duplicates). Usually used with text fields to format the display of data for specific purposes, such as Zip codes, phone numbers, social security numbers and passwords. Can also be used in date/time fields to format dates and times. Whether data must be entered in the field when a new record is created or an existing record is edited. Data is commonly required for things like names, phone numbers and so on. Allows Smart Tags to appear beside data entered (such as to open a calendar in Outlook for a date specified) or to pop up financial data on a stock symbol. An expression (formula) that determines if the data entered is correct (ex. >=1 AND <= 7 to make sure a valid day of the week is entered). Excellent way to help ensure data integrity. The error message displayed if the data entered doesn’t meet the requirements of the Validation Rule. If a rule is entered, a useful error message should be entered here.
Decimal Places
Default Value
Field Size
Format
Indexed
Input Mask
Required
Smart Tags
Validation Rule
Validation Text
Primary Keys • Most tables have a primary key that uniquely identifies each record. • Often a field with “ID” in the name and is often an AutoNumber field. • The Orders table contains the “header” information for an invoice. - Who it was sold to, where to ship it, PO number, etc.
• The Order Details table lists each item ordered, how much it cost, any discount, etc. - OrderID is the primary key in the Orders table and a foreign key in the Order Details table.
• Refer to graphic below. - Likewise, ProductID is the primary key in the Products table and a foreign key in the Order Details table. - Referencing ID fields in other tables reduces errors and makes data entry faster. - All but the simplest of databases should have tables with primary keys defined; useful when creating queries.
Creating Queries • • • •
Queries make databases useful. Data stored in tables is just that - raw data. Queries turn raw data into useful information. Queries are questions you need answered (such as “What are the names and phone numbers of everyone in the marketing department?” or “What are the top selling products?”). • Most queries are created in Design view, but a query that returns all the records (with selected fields returned) and a query that generates summary data (such as total units sold or average selling price) have been automated in wizards. • A few complex tasks can also be accomplished with specialized wizards.
Using Wizards • The Simple Query wizard appears when Create query by using wizard is selected in the main database window. • The other queries that can be created using wizards are available by clicking the New button and selecting from the list. - They are: Crosstab Query Wizard (used to analyze sales by month, for example), Find Duplicate Query Wizard (useful in finding duplicate records, such as phone numbers, especially when data from multiple sources are merged together) and Find Unmatched Query Wizard (used to find items in one table that don’t
have matching entries in another, for example orders without an associated customer). Their use is beyond the scope of this guide.
Using the Simple Query Wizard 1. In the main database window, click the Create query by using wizard link. 2. Select the table or query that contains the desired fields from the drop down menu. Select the desired fields and click the Select to add them to the Selected Item button fields pane. Optionally, repeat this step for any additional tables or queries desired. 3. Click the Next button. 4. Optionally: If any of the selected fields are numeric, the next step will prompt for summary or detailed output. Detail will show all records, but only those fields selected. • If Summary is selected, click the Summary Options button to display another dialog box. In the Summary Options dialog box, all numeric fields will be displayed and you will be prompted which calculations (Sum, Average, Minimum or Maximum) are to be performed. Check the appropriate boxes for the appropriate fields and click OK. Click the Next button. 5. Enter a name for the query then click the Finish button to complete the wizard and open the query.
Query Design View 1
2
3
4
5
7
6
8 9 Microsoft®
• Design view allows great control over the 5. Tables in the query. This area shows all the query design. tables involved in the query and the fields in each. • There are many advanced capabilities; the most 6. QBE Grid. The QBE (Query By Example) common will be described here. grid displays all the fields in the query and • Design view also allows criteria to be specified any specified criteria. which is among the most important reasons 7. Sort direction. Can be Ascending (A-Z), queries exist. Descending (Z-A), or blank (not sorted). If 1. *. Represents all fields in the table. multiple fields are sorted, they will be in the 2. Table Name. Name of the table. order listed in the QBE grid from left to right. 3. Relationship Lines. Denote the 8. Show. If checked, the field is in the output of relationships between the fields in the table. the query; if not, it is only for specifying In the screenshot, OrderID in the Orders criteria. By default, all new fields are table is related to OrderID in the Order checked when added to the QBE grid. Details table and ProductID in the Order 9. Criteria. All criteria specified on the same Details table is related to ProductID in the row is ANDed together (all conditions must be Products table. met); criteria on different rows is ORed. See 4. Primary key. Primary keys are denoted in bold. Specifying Criteria, pg. 5. 4
Query Design Toolbar: Unique Icons Query Type (Select Query selected). The default type is a Select Query, where data may be viewed (and in some cases, modified), but no bulk changes are made. Use the 4 Action Queries, (Delete, Update, Append and Make Table), denoted by ! in the icon, to bulk change the underlying data. Tip: Always first execute any Action Query as a Select Query to verify the correct records are selected. The results of an Action Query can’t be undone.
Specifying Criteria • Most queries are not designed to return a subset of the fields of all records, but rather to answer one or more questions. - The questions are asked by specifying criteria.
Query Type (Make-Table Query selected). Copies records that meet the criteria into a new table (optionally in another database).
Notes: • Criteria may not be specified for the * field (as it represents all fields). • Dates must be surrounded by the # symbol if the data type of the field is Date/Time. • Numbers are entered as is, without any symbols around them. • Text is entered in quotation marks.
Query Type (Crosstab Query selected). Creates a crosstab query.
AND vs. OR
Run. Executes the query.
• All criteria specified on the same row is ANDed together (all conditions must be met); criteria on different rows is ORed. • In other words, all the criteria on row 1 (Between #1/1/2004# AND #3/31/04# AND ProductID=153200) must be met OR all the criteria on row 2 (ProductID=124856 AND Quantity > 15) must be met, etc. See figure on pg. 4. • Within a given field, the AND and OR operators may be specified as well, though typically multiple rows are used. This is a useful shortcut when all of the criteria in all other fields is the same.
Query Type (Delete Query selected). Deletes records that meet the criteria. Query Type (Update Query selected). Updates records that meet the criteria to values specified. Query Type (Append Query selected). Copies records that meet the criteria into another (existing) table (optionally in another database).
Show Table. Allows tables and/or queries to be added to the query. Totals. Allows fields to be totaled and grouped. Many statistical options are available. Top Values. Displays either all records that meet the criteria, or the top 5, 25, or 100 records, or the top 5% or top 25% of records that meet the criteria (other values can be typed in this field if the default values are not appropriate).
Query Design To create a functioning query, several steps must be followed in order. They are: 1. Add one or more tables to the query. 2. If multiple tables are used, specify any relationships between the fields (if necessary; Access® will automatically link fields with the same name in different tables). 3. Add the fields to the query grid to add them to the output of the query. 4. Optionally, specify any desired criteria.
Creating a query in Design view. 1. In the main database window, click the Create query in Design view link. 2. In the Show Table dialog box, select the desired table(s) and/or query(ies) to be the source of data for the new query and click the Add button. 3. Click the Close button. 4. Create any necessary query and/or table relationships, add the desired fields and enter any necessary criteria. 5. When finished, click the Save button to save it and remain in Design view or the Datasheet to save it and view the results of the query. View button
• The Asterisk (“*”) stands for 0 or more characters. In other words, the criteria “*a*” would match all of the following: a, apple, star fruit and banana. See also Like.
Like • The Like keyword is used when searching for a partial match, such as all products that start with the letter A (like “A*”), end with “ing” (like “*ing”), or that have the word “oil” anywhere in the product name (like “*oil*”). • When entering the criteria, the work “like” is not required; it is automatically added.
NOT
Editing a query’s design. 1. In the main database window, select the desired query then click the Design button . 2. Make all desired modifications. to save it and remain in Design view or the Datasheet 3. When finished, click the Save button to save it and view the results of the query. View button
To add a table or query to a query. 1. Click the Show Table button to display the Show Table dialog box. 2. Select the desired table(s) and/or query(ies) to be an additional source of data for the query and click the Add button. 3. Click the Close button.
To delete a table or query from a query. • Select the Title bar (Ex.:
*
) of the desired table and press the Delete key.
Relating Tables • As described in the Primary Keys section of this guide, tables are often related to each other. For the query to return valid results, the relationship between the tables must be specified. • If the related fields have the same name in each table, relationship lines between the fields will be created automatically. If they are named differently, the relationship must be manually specified.
To manually relate two fields. • Select the related field in one table and drag it to the associated field in the second table.
To delete a relationship between two fields. • Select the relationship line and press the Delete key.
To add fields to the QBE grid. 1. Select one or more fields from the field list (use the CTRL key while clicking on fields to select multiple fields). 2. Drag them to the QBE grid. Fields will be inserted at the cursor position when the mouse button is released; any existing fields will be shifted right. 5
• Negates the condition specified, such as NOT “Cherry” returns all products that are not cherry.
NULL • The keyword NULL is used to find fields that are blank (a single space is not considered a blank field, though it appears empty). Often used with the NOT keyword to find fields that are not empty.
Ranges of Data • To specify a range of data, use the keyword Between. • The range is inclusive of both values specified, for example “Between 5 and 10” returns all values from 5 through 10 and “Between #1/1/2004# and #3/31/2004#” returns all values from January 1, 2004 and March 31, 2004.
Prompting for criteria at Run time • If data is to be prompted for when the query is executed, in the criteria field, enter the prompt to be posed to the user in square brackets, like this: Between [Enter a starting date] And [Enter an ending date]. • When the query is executed, the user will see a dialog box with the first prompt, Enter a starting date, a text box, and OK and Cancel buttons; after the user clicks OK, this process will be repeated for the Enter an ending date prompt. • A convenient way to prompt the user for the criteria necessary to answer a specific question without redesigning the query each time.
Viewing the SQL Code
Record Navigation Icons
• Many people use Access as a front end for a SQL (Structured Query ®
1
2
3
4
5
6
7
Language) database; often used for larger, more demanding and/or multi-user database needs. Microsoft®
• As an aid to learning SQL, queries created graphically using the QBE grid may
1.First Record. Moves to the first record in the table/query (if filtered, the first
record that matches the criteria) and makes it the current record.
be viewed in text form (in the SQL format).
2. Previous Record. Moves back a record (relative to the current record) in
• SQL code is used in other places in Access® as well; viewing SQL code created
the table/query (if filtered, the 1st record before the current one that matches the criteria) and makes it the current record. 3. Current Record. Displays the current record number. A specific record can be made the current record by typing its number in the text box. 4. Next Record. Moves forward a record (relative to the current record) in the table/query (if filtered, the 1st record after the current one that matches the criteria) and makes it the current record. 5. Last Record. Moves to the last record in the table/query (if filtered, the last record that matches the criteria) and makes it the current record. 6. New Record. Adds a new record to the end of the table; same as the New Record button . 7. Total Number of Records. Displays the total number of records in the table or query (if filtered, the number of records that meet the criteria).
with the QBE grid is the simplest way to learn to write SQL code. • A query can be written in this format without using the QBE grid at all; when you can do this, you can move on to more complicated SQL queries and tasks. • The font size can also be adjusted for Design and SQL views; this is a program (not database specific) setting.
Viewing the SQL code. 1. If the query is not already open, open it from the Database window. 2. Click the SQL button
.
3. View (and modify, if desired) the SQL code. Any changes will be reflected in the QBE grid as well.
Setting the font size for the Design and SQL views.
Common Keyboard Shortcuts
1. Select Options from the Tools menu. 2. Select the Tables/Queries tab.
When entering data into a table or query, the following keyboard shortcuts can greatly speed up the process: • <ESC>: Once undoes any change to a field, twice undoes all changes to the record. •
+ Semicolon (;): Inserts the current date. • + <SHIFT> + Colon (:): Inserts the current time. • + + <SPACE>: Enters the field’s default value (if specified [in design view for the table for that field]). • + Apostrophe (‘): Copies the same value for field from previous record. • + Plus (+): Adds a new record (at the end of the table). • + Minus (-): Deletes current record.
3. In the Query design font area of the dialog box, select the font and/or size from the drop down menu and click OK.
Table & Query Datasheet Toolbar: Unique Icons Sort Ascending. Sorts the table/query in ascending (A-Z) order based on the currently selected field. If multiple fields are selected, they are sorted in the order they appear, left to right, without regard to the order selected. Sort Descending. Sorts the table/query in descending (Z-A) order based on the currently selected field. If multiple fields are selected, they are sorted in the order they appear, left to right, without regard to the order selected. Filter by Selection. Hides (filters out) all records that do not have the same value as the currently selected field. Filter by Form. Displays all fields with a drop down menu for each, listing all unique values for the field. One value per field may be selected at a time. All criteria is ANDed together. To OR criteria, click the Or tab(s) at the bottom of the page. Apply/Remove Filter. If criteria have been specified using the Filter by Form method, click this button to apply the criteria. Once criteria have been applied (using either filter method), click the button again to remove the filter and display all records. Find. Displays the standard Find dialog box. Will also replace data, if desired. Individual fields or all fields of the table/query may be searched. New Record. Adds a new record to the end of the table. Data is always appended to the end of the table, regardless of indexes, primary keys, etc. until the table/query is closed and reopened or manually sorted. Delete Record. Deletes the current (or selected) record(s). Confirmation will be prompted for and if given, the action cannot be undone; the data is permanently lost.
Price: U.S.$5.95 / Can.$8.95 Author: John Hales A+, Network+, MCSE, CNE ISBN-13: 978-142320337-7 ISBN-10: 142320337-2
Viewing Object Dependencies • Dependencies between objects are an integral part of a database. • When a table, query, etc. is deleted, it may in fact be needed still by another object. • Unintentionally, multiple objects may be affected. • To avoid this always use this new feature before deleting an object.
Viewing the dependencies on an object. 1. Select the object in the Database window. 2. Select Object Dependencies from the View menu. 3. In the Object Dependencies task pane, click either Objects that depend on me to view other objects dependent on this object OR Objects that I depend on to view objects that must exist for this object to be useful and function properly. 4. Access® will break the dependencies down into the basic object categories (Tables, Queries, Forms and Reports). If there are no dependencies, the text “None” will be listed, otherwise, a list of top level objects will be displayed with a plus sign in front. 5. Click the plus sign in front of each object to view the dependencies the object has on other objects as needed. Objects with no further dependencies will not have a plus sign in front of them.
hundreds of titles at
quickstudy.com
Customer Hotline # 1.800.230.9522 We welcome your feedback so we can maintain and exceed your expectations.
All rights reserved. No part of this publication may be reproduced or transmitted in any form, or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system, without written permission from the publisher. ©2003 BarCharts, Inc. 0107 Screen shots may vary depending on the version installed. This guide is based on the software version shipping at the time of publication and is accurate to that version. Microsoft ®, Access®, MSN ®, and Windows ® are either registered trademarks or trademarks of Microsoft Corporation ® in the United States and/or other countries. Screen shot(s) reprinted by permission from Microsoft Corporation ®.
6