Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)
-
Upload
jasper-wilcox -
Category
Documents
-
view
219 -
download
1
Transcript of Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)
![Page 1: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/1.jpg)
Introduction of Running Microsoft Access 97
Source: USC Database Course (SC485)
![Page 2: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/2.jpg)
Main Topics
Building a DatabaseWorking with DataUsing FormsCreating an Application
![Page 3: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/3.jpg)
Building a Database
Conceptual data design E-R model
Creating tables Reducing E-R model to tables Creating tables in MS Access 97
Modifying database design Deleting and renaming tables
Modifying fields within a table
![Page 4: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/4.jpg)
E-R Model
Entity setsRelationship setskeysMapping constrains
Entity EntityRelationship
Key Key Attribute Attribute
N 1
![Page 5: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/5.jpg)
Reducing E-R Model to Tables
Strong entity sets Loan (loan-number, amount)
Weak entity sets Payment (payment-number, pay-date, pay-amount)
Relationship sets Redundancy of tables (links weak and strong
entity) Loan-Payment (loan-number, payment-number)
Combination of tables (many-to-one) Branch(name, location)---has---account(account-number,
amount)
![Page 6: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/6.jpg)
Creating tables in MS Access 97
1. Create a blank database (courses), click New to create a new table.
![Page 7: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/7.jpg)
Creating tables in MS Access 97
2. Choose the Design View and click OK.
![Page 8: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/8.jpg)
Creating tables in MS Access 97
3. Input the Fields Names, Descriptions, and select Data Types.
![Page 9: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/9.jpg)
Creating tables in MS Access 97
4. Define the primary key.
![Page 10: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/10.jpg)
Creating tables in MS Access 97
5. Add indexes.
![Page 11: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/11.jpg)
Creating tables in MS Access 97
6. Input Index Name, choose Field Name and Sort Order.
![Page 12: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/12.jpg)
Creating tables in MS Access 97
7. Save the table.
![Page 13: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/13.jpg)
Deleting and Renaming Tables
Right-click the mouse on the table name that you want to delete or rename.
![Page 14: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/14.jpg)
Modifying Fields within a Table
Changing field name Open the table in Design View and change the field name
![Page 15: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/15.jpg)
Modifying Fields within a Table
Inserting and deleting fields Open the table in Design View, use the toolbar or menus.
![Page 16: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/16.jpg)
Modifying Fields within a Table
Copying fields Open the table in Design View, use the Edit menu.
![Page 17: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/17.jpg)
Modifying Fields within a Table
Moving fields Open the table in Design View, drag and drop the row
selector.
![Page 18: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/18.jpg)
Working with Data
Using Datasheets view, change, sort and search data
Creating and using queries Select queries Action queries
Importing, linking and exporting data ODBC (Open Database Connectivity)
SQL
![Page 19: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/19.jpg)
Using Datasheets
View data
![Page 20: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/20.jpg)
Using Datasheets
Changing data (adding, modifying, copying, deleting)
![Page 21: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/21.jpg)
Using Datasheets
Modifying datasheet format Using the Format menu, you can:
Selecting fonts Changing row height and column width Moving columns Hiding and showing columns freezing columns Removing gridlines
![Page 22: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/22.jpg)
Using Datasheets
Sorting and searching data Sorting using toolbar and searching using Find... in
Edit menu
![Page 23: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/23.jpg)
Creating and using queries
Select Queries 1. Switch to the Queries folder.
![Page 24: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/24.jpg)
Creating and using queries
Select Queries 2. Open a new query in Design View.
![Page 25: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/25.jpg)
Creating and using queries
Select Queries 3. Choose the table(s) used to create the query.
![Page 26: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/26.jpg)
Creating and using queries
Select Queries 4. Select the display fields of the query and input the selection
criteria.
![Page 27: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/27.jpg)
Creating and using queries
Select Queries 5. Save the query.
![Page 28: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/28.jpg)
Creating and using queries
Select Queries 6. Double-click the query name or use Open to run the query.
![Page 29: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/29.jpg)
Creating and using queries
Action queries Update Query Append Query Delete Query Make-Table Query
Example: Create an update query
![Page 30: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/30.jpg)
Creating and using queries
Create an update query 1. Create an select query with the criteria of the update query.
![Page 31: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/31.jpg)
Creating and using queries
Create an update query 2. Convert the select query to update query.
![Page 32: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/32.jpg)
Creating and using queries
Create an update query 3. Specify how you want the data changed.
![Page 33: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/33.jpg)
Importing, linking and exporting data
ODBC (Open Database Connectivity) Create a new ODBC data source
Importing Linking Exporting
![Page 34: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/34.jpg)
ODBC
ODBC (Open Database Connectivity) is a SQL database interface developed by Microsoft. It allow one database product that “speaks” SQL be able to “talk” to other database product that understand SQL.
With ODBC, Microsoft Access can import (copy in) or link (connect to) data that is in text files, spreadsheets, other Access database, dBASE, Paradox, Microsoft FoxPro, and other SQL database that support ODBC. Microsoft Access can also export (copy out) data from Access tables to the databases, spreadsheets, Web pages, or test files of other application.
![Page 35: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/35.jpg)
Create a New ODBC Data Source
1. Open the control Panel, and click the 32bit ODBC.
![Page 36: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/36.jpg)
Create a New ODBC Data Source
2. In the User DSN folder, choose Add… to add your new data source.
![Page 37: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/37.jpg)
Create a New ODBC Data Source
3. Select the driver for the new data source.
![Page 38: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/38.jpg)
Create a New ODBC Data Source
4. Input the data source name and create the database.
![Page 39: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/39.jpg)
Create a New ODBC Data Source
5. A new user data source forCS485 is added.
![Page 40: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/40.jpg)
Importing Data
Importing dBASE files Importing Paradox files Importing FoxPro files Importing spreadsheet files Importing text files Importing Access objects Importing SQL tables
![Page 41: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/41.jpg)
Importing Data
Importing dBASE files, Paradox files, FoxPro files 1. Open the database to import the file. 2. Choose the Get External Data from the File menu, then choose
the Import submenu.
3. In Import dialog box, select the appropriate file type and file name.
4. Click the Import button to import the file. 5. Access responses with a message box that informs the result of
the importing procedure (i.e., successfully imported ‘xxxxx’). 6. Click the OK button to confirm the import procedure.
![Page 42: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/42.jpg)
Importing Data
Importing spreadsheet Steps 1-4 are the same as previous one. 5. An Import Spreadsheet Wizard dialog box is popped up.
Simply follow the instruction of the wizard to finish specifying the detail of the table (i.e., choose whether first row contains column heading, select index and key, etc.).
6. Access responses with a message box that informs the result of the importing procedure.
7. Click the OK button to confirm the import procedure.
![Page 43: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/43.jpg)
Importing Data
Importing text files Steps 1-4 are the same as previous one. 5. An Import Text Wizard dialog box is popped up. Simply
follow the instruction of the wizard to finish specifying the detail of the table (i.e., choose whether the data format is delimited or fixed width, whether first row contains column heading, to import to an existing table or a new table, etc.).
6. Access responses with a message box that informs the result of the importing procedure.
7. Click the OK button to confirm the import procedure.
![Page 44: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/44.jpg)
Importing Data
Importing Access objects Steps 1-4 are the same as previous one. 5. An Import Objects dialog box is popped up. Choose the
object to be imported and confirm the importing procedure.
![Page 45: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/45.jpg)
Importing Data
Importing SQL tables
![Page 46: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/46.jpg)
Linking Data
Linking dBASE files Linking Paradox files Linking FoxPro files Linking spreadsheet files Linking text files Linking Access objects Linking SQL tables
![Page 47: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/47.jpg)
Importing vs. Linking
Importing File is relatively small. Data is not changed frequently by users of other database
application. Data need not to be shared with other database application. Best performance is desired.
Linking File is large (i.e., larger than maximum capacity of local Access
database [1 GB]). Data is changed frequently by users of other database application. Data need to be shared over network with other database
applications. Performance does not matter.
![Page 48: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/48.jpg)
Exporting Data
Exporting to dBASE file Exporting to Paradox files Exporting to FoxPro files Exporting to spreadsheet files Exporting to text files Exporting to Access objects Exporting to SQL tables Exporting to a web page
![Page 49: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/49.jpg)
SQL
In Microsoft Access, you can use SQL to: create tables build select queries build append queries build delete queries build update queries
![Page 50: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/50.jpg)
SQL
1. Open a new query in design view.
![Page 51: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/51.jpg)
SQL
2. Close the Show Table Dialog box without adding any table.
![Page 52: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/52.jpg)
SQL
3. Switch the query to SQL View.
![Page 53: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/53.jpg)
SQL
4. Write the SQL statement and save the query.
![Page 54: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/54.jpg)
Using Forms
Forms are the primary interface between users and Microsoft Access application.
Using Forms in Microsoft Access, you can: Displaying and editing data Controlling application flow Accepting input Displaying message Printing information
![Page 55: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/55.jpg)
Using Forms
Building forms Building forms from scratch Building forms using Form Wizard Advanced form design
![Page 56: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/56.jpg)
Building Forms from Scratch
1. Open a new form in Design View.
![Page 57: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/57.jpg)
Building Forms from Scratch
2. Use the tools in the Toolbox to set the layout of the form.
![Page 58: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/58.jpg)
Building Forms from Scratch
3. Add the command buttons.
![Page 59: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/59.jpg)
Building Forms from Scratch
4. Set the properties of the controls (i.e., specify the event procedure of On Click for the Search button) and save the form.
![Page 60: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/60.jpg)
Building Forms using Form Wizard
1. Open a new form using Form Wizard.
![Page 61: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/61.jpg)
Building Forms using Form Wizard
2. Select the fields to be displayed on the form.
![Page 62: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/62.jpg)
Building Forms using Form Wizard
2. Follow the instructions to select the layout (i.e., Columnar) and style (i.e., Stone) of the form.
3. Specify the name and save the form.
![Page 63: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/63.jpg)
Advanced Form Design
Basing a form on a multiple-tables query Creating Multiple-page forms Creating and embedding subform Linking forms with a command button
Example: a simple search on Course and Faculty tables A main form (search) used to input the search condition. A second form (results) used to display the the result of
the search.
![Page 64: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/64.jpg)
Advanced Form Design
1. Create a query (used for the results form) based on the course and faculty tables.
![Page 65: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/65.jpg)
Advanced Form Design
2. Create a new form as the results form, specify the query created in step 1 as the data source of the form.
![Page 66: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/66.jpg)
Advanced Form Design
3. Set the layout of the form.
![Page 67: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/67.jpg)
Advanced Form Design
4. Set the properties of the form and controls, and save the from.
![Page 68: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/68.jpg)
Advanced Form Design
5. Build the main form (refer to Building Forms from Scratch).
![Page 69: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/69.jpg)
Advanced Form Design
6. Write the event procedure for the Search and Close button. Search
/* check input and form the search condition */If Not IsNothing(Me!FID) Then searchCondition = " FID = " & Me!FID… …/* open the subform results with the desired search condition */
DoCmd.OpenForm FormName:="results", whereCondition:=searchCondition
… ...
CloseDoCmd.Close
![Page 70: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/70.jpg)
Advanced Form Design
7. Save the main form and run it.
![Page 71: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/71.jpg)
Advanced Form Design
8. The form results is shown after click the Search button.
![Page 72: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/72.jpg)
Creating an Application
Macros Creating Macros Automating applications with Macros
VBA (Visual Basic Application) Visual Basic in MS Access Automating applications with Visual Basic
![Page 73: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/73.jpg)
Macros
Using macros in MS Access, you can: Open any table, query, form, or report in any available view. Rename any objects in the database. Execute other macros or VBA functions. Emulate keyboard actions and supply input to system dialog
boxes. Execute any command on any Access menu. Display informative message or sound a beep to draw
attention. Send the data from a table, query, form or report to an output
file. … ...
![Page 74: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/74.jpg)
Creating Macros
1. Switch to the Macros folder.
![Page 75: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/75.jpg)
Creating Macros
2. Open a new Macro.
![Page 76: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/76.jpg)
Creating Macros
3. Select the Action, and input the Condition and Comment. Input or choose the Action Arguments, and save the macro.
![Page 77: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/77.jpg)
Creating Macros
4. Run the macro.
![Page 78: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/78.jpg)
Automating Applications with Macros
Example: A database startup routine Display a Welcome message when the database application
start up. Next open a form that used to display course information of
CS department. Display the information of course cs485 as default view.
![Page 79: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/79.jpg)
Automating Applications with Macros
Example: A database startup routine 1. Create a new macro.
![Page 80: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/80.jpg)
Automating Applications with Macros
Example: A database startup routine 2. Specify the actions of the startup routine.
![Page 81: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/81.jpg)
Automating Applications with Macros
Example: A database startup routine 3. Save the macro as Autoexec.
![Page 82: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/82.jpg)
Automating Applications with Macros
Example: A database startup routine 4. Open the database that contains the macro Autoexec.
![Page 83: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/83.jpg)
Visual Basic in MS Access
Modules Module Objects Forms or Report Modules
VBA Debug Tools Setting Breakpoints Using Debug Window
Collections and Objects
![Page 84: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/84.jpg)
Modules
Module Objects
![Page 85: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/85.jpg)
Modules
Forms or Report Modules
![Page 86: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/86.jpg)
VBA Debug Tools
Setting Breakpoints
![Page 87: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/87.jpg)
VBA Debug Tools
Using Debug Window
![Page 88: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/88.jpg)
Collections and Objects
Collections Forms Collection, Reports Collection, Modules Collection
Objects Forms, Reports, Module
Forms![search] Controls
Me![FID] DoCmd, Screen
DoCmd.OpenForm FormName:="results", whereCondition:=searchCondition
Database, RecordSet Dim db As Database | Set db = CurrentDb() Dim rcds As RecordSet | Set rcds =
db.OpenRecordSet(“queryName”)
![Page 89: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/89.jpg)
Automating applications with Visual Basic
Example: A public function that checks user inputs of a form
Function IsNothing(v As Variant) As Integer IsNothing = True Select Case VarType(v) Case vbEmpty Exit Function Case vbNull Exit Function Case vbBoolean If varToTest Then IsNothing = False Case vbByte, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency If v <> 0 Then IsNothing = False Case vbDate IsNothing = False Case vbString If (Len(v) <> 0 And v <> " ") Then IsNothing = False End SelectEnd Function
![Page 90: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/90.jpg)
Automating applications with Visual Basic
Example: Get search conditions from user input
![Page 91: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/91.jpg)
Automating applications with Visual Basic
Example: Use SQL query to check result before display the form
![Page 92: Introduction of Running Microsoft Access 97 Source: USC Database Course (SC485)](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649e725503460f94b7183d/html5/thumbnails/92.jpg)
Macros vs. VBA
Macros Don’t need to trap errors Application consists of only a few forms. Defining alternative actions for certain keystrokes. Creating a startup routine that runs when the database opens.
VBA Need to discrete error handling. Define new functions. Handle events that pass parameters or accept return values. Create new objects (tables, queries, forms…) from application
code Directly call Windows API functions. Manipulate data in a recordset on a record-by-record basis.