Access Project 8 Using Visual Basic for Applications (VBA) and Creating Multi-Page Forms.

Slides:



Advertisements
Similar presentations
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
Advertisements

Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Chapter 5 Multitable Forms
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Microsoft Office 2007 Access Chapter 4 Creating Reports and Forms.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window.
Staff Development Daze June 27 & 28 Tony Gauvin. Schedule  Monday June 27  Monday June 27  9:00 – 12:00 Basic Excel  12:00 – 1:00 Lunch for all workshop.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 3 Maintaining a Database Using the Design and Update Features of Access.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Web Feature Sharing Data among Applications.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Access Tutorial 10 Automating Tasks with Macros
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 4 Reports, Forms, and Combo Boxes.
Chapter 3 Maintaining a Database
Tutorial 6 Using Form Tools and Creating Custom Forms
® Microsoft Access 2010 Tutorial 6 Using Form Tools and Creating Custom Forms.
Advanced Form Techniques
Chapter 1 Databases and Database Objects: An Introduction
Using Form Tools and Creating Custom Forms Microsoft Access 2010.
Chapter 6 Advanced Report Techniques
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Web Feature Data Access Pages.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 5 Enhancing Forms with OLE Fields, Hyperlinks, and Subforms.
Using Visual Basic for Applications (VBA) – Project 8.
Microsoft Office 2007 Access 2007 Chapter 7 Advanced Report Techniques.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Switchboards, PivotTables, and PivotCharts.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 5 Enhancing Forms with OLE Fields, Hyperlinks, and Subforms.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
COMPREHENSIVE Access Tutorial 6 Using Form Tools and Creating Custom Forms.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Creating an Application System Using Macros, Wizards, and the Switchboard.
Modify Tables and FieldsModify Tables and Fields Lesson 4 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft.
1 After completing this lesson, you will be able to: Create a form using AutoForm. Create a form using the Form Wizard. Add controls to a form. Modify.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Integrating Office 2003 Applications and the World Wide Web
Using Macros, Switchboards, PivotTables, and PivotCharts
Maintaining a Database Using the Design and Update Features of Access
Maintaining a Database
Access Chapter 2 Querying a Database.
Plug-In T7: Problem Solving Using Access 2007
Microsoft Official Academic Course, Microsoft Access 2013
Querying a Database Using the Select Query Window
Access SQL Feature Using SQL.
Administering a Database System
Sharing Data among Applications
Creating and Using a Database
Enhancing Forms with OLE Fields, Hyperlinks, and Subforms
Access Chapter 5 Multi-Table Forms.
Chapter 7 Advanced Form Techniques
Creating Reports and Forms
Microsoft Office Access 2003
Microsoft Office Access 2003
Advanced Report Techniques
Microsoft Office Access 2003
Microsoft Office Access 2003
Chapter 1 Databases and Database Objects: An Introduction
Microsoft Office Access 2003
Defining the Fields in a Table
Chapter 8 Using Document Collaboration and Integration Tools
Tutorial 10 Automating Tasks with Macros
Presentation transcript:

Access Project 8 Using Visual Basic for Applications (VBA) and Creating Multi-Page Forms

Objectives Use VBA Create functions in a standard module Test functions Use the functions in a query Associate code with an event

Objectives Create Sub procedures Correct errors using debugger Create code to update controls Create a function to run a command Create a form using Design view

Objectives Add a tab control Add a subform control to a form Add a chart to a form Add an ActiveX control to a form

Creating Functions in a Standard Module Open the Ashton James College database in Microsoft Office Access 2003 as described on page AC 462 Click Modules on the Objects bar in the Database window Click the New button on the Database window toolbar and be sure the window is maximized Type Function PromoFactor(Client_Type) and then press the ENTER key Type the statements shown in lines 2 through 12 of Table 8-10 on page AC 467

Creating Functions in a Standard Module Use the DOWN ARROW key to move the insertion point below the End Function statement Type Function PromoAmount(Client_Type, Current_Due) and then press the ENTER key Type the statements shown in lines 2 through 4 of Table 8-11 on page AC 468 Click the Save button on the Standard toolbar, type Promo Modules as the module name, and then click the OK button

Creating Functions in a Standard Module

Testing Functions in the Immediate Window Click View on the menu bar, and then click Immediate Window on the View menu Type ?PromoFactor(“EDU”) in the Immediate window, and then press the ENTER key Type ?PromoAmount(“EDU”,10000) in the Immediate window, and then press the ENTER key Click the Close button for the Microsoft Visual Basic – Ashton James College – [Promo Modules (Code)] window to close the window

Testing Functions in the Immediate Window

Using Functions in a Query In the Database window, click Tables on the Objects bar, and then click Client, if necessary Click the New Object button arrow on the Database toolbar, and then click Query Be sure Design View is selected, and then click the OK button Be sure the Query1 : Select Query window is maximized

Using Functions in a Query Resize the upper and lower panes and the Client field list so all the fields in the Client table appear One-by-one double-click the Client Number, Name, Current Due, and Client Type fields Right-click the column following Client Type, and then click Zoom on the shortcut menu Type Promo Factor:PromoFactor([Client Type]) as the expression

Using Functions in a Query Click the OK button Right-click the column following Promo Factor, and then click Zoom on the shortcut menu Type Promo Amount:PromoAmount([Client Type],[Current Due])*1.00 as the expression

Using Functions in a Query Right-click the Promo Amount column, click Properties on the shortcut menu, click the Format property on the General tab, click the Format property box arrow, and then click Currency Close the property sheet by clicking its Close button Run the query, resize each column to best fit the data by double-clicking the right border of the column heading Close the window containing the query by clicking its Close Window button, click the Yes button to save the query, type Promo Amount Query as the name, and then click the OK button

Using Functions in a Query

Associating Code with an Event Add the necessary command buttons and controls to the form, as instructed on pages AC 475 – AC 481 Right-click the cmdPromo button (the button whose caption is Show Promotion), click Properties on the shortcut menu, scroll down so the On Click property appears, and then click the On Click property Click the Build button, click Code Builder in the Choose Builder dialog box, and then click the OK button Close the Immediate window by clicking its Close button so more of the Visual Basic code is visible Type the statements on lines 2 through 10 shown in Table 8-12 on page AC 482

Associating Code with an Event

Creating Sub Procedures Click the Insert Module button arrow on the Standard toolbar Click Procedure Type ShowPromotion as the name of the procedure in the Add Procedure dialog box

Creating Sub Procedures Click the OK button and then type the statements on lines 2 through 4 for the ShowPromotion procedure shown in Table 8-13 on page AC 484 Use the techniques in the previous steps to create the HidePromotion procedure from Table 8-14 on page AC 484 Click the Close button for the Microsoft Visual Basic – Ashton James College – [Form_Client Update Form (Code)] window and then click the Close button for the cmdPromo property sheet

Creating Sub Procedures

Creating Code to Update Controls Right-click the form selector (the small box in the upper-left corner of the form), click Properties, and then click the On Current property Click the Build button Click in front of the letter E in End Sub Add the additional statement shown in Figure 8-41 on page AC 489 Click the Insert Module button arrow on the Standard toolbar, click Procedure, be sure the Sub and Public option buttons are selected in the Add Procedure dialog box, type UpdatePromoData as the name of the procedure, and then click the OK button

Creating Code to Update Controls Type the statements on lines 2 and 3 for the UpdatePromoData procedure shown in Table 8-15 on page AC 488 Click the Close button for the Microsoft Visual Basic – Ashton James College – [Form_Client Update Form (Code)] window to close the window Close the Form property sheet Right-click the combo box for Client Type, click Properties on the shortcut menu, click the After Update property, click the Build button, click Code Builder in the Choose Builder dialog box, and then click the OK button Add the statement shown in Figure 8-43 on page AC 490 to the Combo18_AfterUpdate procedure

Creating Code to Update Controls Click the Close button for the Microsoft Visual Basic – Ashton James College – [Form_Client Update Form (Code)] window to close the window Click the Close button for the Combo Box: Combo 18 property sheet Right-click the control for the Current Due field (the white space, not the label), click Properties on the shortcut menu, click the After Update property, click the Build button, click Code Builder in the Choose Builder dialog box, and then click the OK button Add the statement shown on the following slide to the Current_Due_AfterUpdate procedure Click the Close button for the Microsoft Visual Basic – Ashton James College – [Form_Client Update (Code)] window to close the window and then close the Text Box: Current Due property sheet

Creating Code to Update Controls

Creating a Function to Run a Query Click Modules on the Objects bar in the Database window, right-click Promo Modules, and then click Design View on the shortcut menu Be sure the window is maximized Click below the End Function for the second function (PromoAmount), type Function RunPromoAmountQuery(), and then press the ENTER key Type the statements on lines 2 through 12 shown in Table 8-17 on page AC 493 Click the Close button for the Microsoft Visual Basic – Ashton James College – [Promo Modules (Code)] window to close the window

Creating a Function to Run a Query Click Forms on the Objects bar in the Database window, right-click the Client Update Form, click Design View on the shortcut menu, and then maximize the window if it already is not maximized Right-click the button whose caption is Run Promotion Query, click Properties on the shortcut menu, click the On Click property in the Command Button:cmdPromoQuery property sheet, and then type =RunPromoAmountQuery() as the value for the On Click property Close the property sheet by clicking its Close button, and then click the Close Window button for the window containing the form design When asked if you want to save your changes, click the Yes button

Creating a Function to Run a Query

Creating a Form If necessary in the Database window, click Tables on the Objects bar, and then click Trainer Click the New Object button arrow on the Database toolbar Click Form Be sure Design View is selected, and then click the OK button

Creating a Form Be sure the field list appears and the window is maximized. (If it does not, click the Field List button on the Form Design toolbar) Drag the Trainer Number, First Name, and Last Name fields to the approximate positions shown on the following slide Move the attached labels for the First Name and Last Name fields to the positions shown in the figure by dragging their move handles Close the field list by clicking its Close button

Creating a Form

Using Tab Controls to Create a Multi-Page Form Click the Tab Control tool and move the mouse pointer to the approximate location shown in Figure 8-58 on page AC 506 Click the position shown in Figure 8-58 Right-click the tab control, and then click Insert Page on the shortcut menu Click the leftmost tab, right-click the tab control, and then click Properties on the shortcut menu Change the name to Datasheet

Using Tab Controls to Create a Multi-Page Form Close the property sheet by clicking its Close button Right-click the middle tab, select Properties on the shortcut menu, change the name to Charts, and then close the property sheet Right-click the rightmost tab, select Properties on the shortcut menu, change the name to Web, and then close the property sheet Click the leftmost tab Resize the tab control to the approximate size shown on the following slide by dragging the appropriate sizing handles

Using Tab Controls to Create a Multi-Page Form

Placing a Subform Be sure the Control Wizards tool is selected, click the Subform/Subreport tool in the toolbox, and then move the mouse pointer to the approximate position shown in Figure 8-62 on page AC 508 Click the position shown in Figure 8-62. Be sure the “Use existing Tables and Queries” option button is selected Click the Next button Click the Tables/Queries box arrow and then click the Clients and Course Offerings query

Placing a Subform Click the Add All fields button Click the Next button Be sure the “Choose from a list” option button is selected

Placing a Subform Type Course Offerings for Trainer as the name of the subform and then click the Finish button If the window is no longer maximized, maximize the window If a field list appears, close the field list Resize the subform to the approximate size shown on the following slide by dragging the appropriate sizing handles

Placing a Subform

Inserting Charts In the Ashton James College: Database window, be sure Forms is selected on the Objects bar, right-click Trainer Data and then click Design View on the shortcut menu Be sure the window is maximized, and then close the field list if it appears Click the Charts tab and then click Insert on the menu bar Click Chart and then move the pointer to the approximate position shown in Figure 8-69 on page AC 512 Click the position shown in Figure 8-69

Inserting Charts Click the Queries option button in the Chart Wizard dialog box, click the Clients and Course Offerings query, and then click the Next button Select the Course Number and Total Hours fields by clicking them and then clicking the Add Field button Click the Next button Be sure the chart in the upper-left corner is selected

Inserting Charts Click the Next button Click the Next button, type Total Hours by Course as the title, and then click the Finish button Use the techniques shown in Steps 1 through 7 on pages AC 511 through AC 514 to add a second chart at the position shown on the following slide. In this chart, select Hours Spent instead of Total Hours and type Hours Spent by Course as the title of the chart instead of Total Hours by Course

Inserting Charts

Adding an ActiveX Control Click the third tab, the one labeled Web on the tab control Click Insert on the menu bar, and then click ActiveX Control on the Insert menu to display the Insert ActiveX Control dialog box Select Microsoft Web Browser in the Select an ActiveX Control list and then click the OK button Be sure the Web browser just added is selected Drag the right sizing handle and then drag the lower sizing handle to change the size of the Web Browser control to the one shown in Figure 8-77 on page AC 516

Adding an ActiveX Control Right-click the control and then click Properties on the shortcut menu to display the property sheet Note the number of your Web Browser control, which may be different from the one shown in Figure 8-77 on page AC 516 Click the Close button for the property sheet Right-click the form selector, click Properties on the shortcut menu, scroll down so the On Load property appears, and then click the On Load property

Adding an ActiveX Control Click the Build button, click Code Builder in the Choose Builder dialog box, and then click the OK button Type me!WebBrowser1.navigate "http://www.scsite.com/ac2003/ ajc.html" as the statement in the Form_Load procedure Click the Close button for the Microsoft Visual Basic – Ashton James College – [Form_Trainer Data (Code)] window to close the window Click the Close button for the property sheet

Adding an ActiveX Control

Summary Use VBA Create functions in a standard module Test functions Use the functions in a query Associate code with an event

Summary Create Sub procedures Correct errors using debugger Create code to update controls Create a function to run a command Create a form using Design view

Summary Add a tab control Add a subform control to a form Add a chart to a form Add an ActiveX control to a form

Access Project 8 Complete