Working with option button, check box, and list box controls Visual Basic for Applications 13.

Slides:



Advertisements
Similar presentations
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Advertisements

Programming with Microsoft Visual Basic th Edition
WORKING SMART Crystal M. Thomas Henrico County DSS (804) POSSESS Central Region Member October 31, 2007.
Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 6: Managing Multiple Worksheets and Workbooks
Using Microsoft Office Excel 2007
String Variables Visual Basic for Applications 4.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Using the Visual Basic Editor Visual Basic for Applications 1.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
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)
1 Excel Lesson 3 Organizing the Worksheet Microsoft Office 2010 Introductory Pasewark & Pasewark.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Access Tutorial 10 Automating Tasks with Macros
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Exploring Formulas.
© 2002 ComputerPREP, Inc. All rights reserved. Word 2000: Forms, Merges, and Macros.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Customizing Microsoft Project
Excel 2007 Part (2) Dr. Susan Al Naqshbandi
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall.1 Exploring Microsoft Office Excel Copyright © 2008 Prentice-Hall. All rights.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
XP New Perspectives on Introducing Microsoft Office XP Tutorial 1 1 Introducing Microsoft Office XP Tutorial 1.
Using the Select Case Statement and the MsgBox Function (Unit 8)
* A form is another means of viewing information from a table & displaying the information one record at a time. Access Lesson 1 Lesson Plans Michele Smith.
Object Variables Visual Basic for Applications 3.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Exploring Microsoft Office Word 2007 Chapter 7 The Advanced User Robert Grauer, Keith Mulbery,
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
Introducing Access Lesson 1. Objectives Start Access and explore the Database window Explore database objects Enter, edit, and delete records in a datasheet.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
11 Exploring Microsoft Office Excel 2007 Chapter 4: Working with Large Worksheets and Tables Chapter 04 - Lecture Notes (CSIT 104)
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Excel Project 5 Creating, Sorting, and Querying a List.
1 Lesson 22 Getting Started with Access Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Microsoft Access Lesson 1 Lexington Technology Center February 11, 2003 Bob Herring On the Web at
Working with Numeric Variables (Unit 6) Visual Basic for Applications.
Numeric Variables Visual Basic for Applications 6.
XP New Perspectives on Integrating Microsoft Office XP Tutorial 2 1 Integrating Microsoft Office XP Tutorial 2 – Integrating Word, Excel, and Access.
Lesson 17 Getting Started with Access Essentials
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
OCC Network Drives  H:\  P:\ 
The Object Model Visual Basic for Applications 2.
Key Applications Module Lesson 21 — Access Essentials
Date Variables Visual Basic for Applications 5. Objectives n In this tutorial, you will learn how to: n Reserve a Date variable n Use an assignment statement.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 15 Advanced Tables.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Microsoft Access 2010 Chapter 10 Administering a Database System.
FIRST COURSE Word Tutorial 3 Creating a Multiple-Page Report.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Excel 2010 © 2011 The McGraw-Hill Companies,
Microsoft Access Lesson 2 Lexington Technology Center February 13, 2003 Bob Herring On the Web at
1.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
Advanced Repetition Structure and String Functions (Unit 10) Visual Basic for Applications.
Microsoft® Excel Create an Excel table. 1 Work with the Table Tools Design tab. 2 Sort and filter records in a table. 3 Identify structured references.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
An electronic document that stores various types of data.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Excel Tutorial 8 Developing an Excel Application
Lesson 13 Working with Tables
Microsoft Excel 2007 – Level 2
Presentation transcript:

Working with option button, check box, and list box controls Visual Basic for Applications 13

Objectives n In this unit, you will learn how to: n Create and use option button, check box, and list box controls n Create an option group n Select the default option button and list box item n Use the Sort method in Excel n Use the AddItem method to display items in a list box n Use the QueryClose event in Word n Use the List Box Control’s Column property in Access 13

Concept Lesson: More Dialog Box Controls n Option button, check box, and list box controls provide a means by which the user can enter data into a dialog box 13 Exhibit 13-1: The Calculate Price dialog box

The Option Button Control n You use the option button control in a dialog box when you want to limit the user to only one choice in a group of two or more related and mutually exclusive choices n In all Microsoft Office applications except Access, you can create a group of option buttons, called an option group, by setting each button’s GroupName property to the same value n You create an option group in Microsoft Access by placing the option buttons in an option group control, which is a rectangular control in Access that acts as a container for option button, check box, and toggle button controls 13

The Option Button Control n The minimum number of option buttons in a group is two, because the only way to deselect an option button is to select another option button n The selected button, referred to as the default option button, should be the button that represents the user’s most likely choice n In all Microsoft Office applications except Access, you select the default option button by setting the button’s Value property to the Boolean value True n In Access, you set the option group control’s DefaultValue property to a number that represents the option button in the group that you want to be the default button 13

The Check Box Control 13 n You use the check box control to allow the user to select any number of choices from a set of one or more independent and nonexclusive choices n Any number of check boxes in a dialog box can be selected at the same time n The Windows standard is to have all check boxes unselected when the dialog box first opens

The List Box Control n A list box control can be used to display a set of predefined choices from which the user can select only one of the choices n This type of list box is called a single selection list box n When a user selects an item in a single selection list box, the item is assigned automatically to the list box control’s Value property n The ListIndex property keeps track of the various items in a list box n The Windows standard is to display, in the list box, a minimum of three items and a maximum of eight items at a time 13

Summary To limit the user to only one choice in a group of related and mutually exclusive choices: n Use either the option button control or the list box control n The minimum number of option buttons in a group is two; the recommended maximum is seven n Display, in a list box, a minimum of three items and a maximum of eight items at a time 13

Summary To create a group of option buttons: n In all Microsoft Office applications except Access, set each button’s GroupName property to the same value To select the default option button: n In all Microsoft Office applications except Access, set the option button control’s Value property to the Boolean value True 13

Summary To select the default list box item: n In all Microsoft Office applications except Access, set the list box control’s ListIndex property to a number that represents the item’s location in the list n In Access, assign the item, entered as a string, to the list box’s Default Value property 13

Summary To determine which item is selected in a list box that allows one selection only: n The list box control’s ListIndex property contains a number that represents the item’s location in the list n In all Microsoft Office applications except Access, the list box control’s Value property contains the selected item 13

Summary To allow the user to select any number of choices from a set of one or more independent and nonexclusive choices: n Use the check box control. Check boxes typically are unselected when the dialog box first opens To select a check box: n Set the check box control’s Value property to the Boolean value True 13

Excel Lesson: Viewing the Sales Workbook n Before creating the custom dialog box and macro that you will use to calculate a salesperson’s total and average sales, view the workbook 13

The Custom Dialog Box You Will Complete in this Lesson 13 Exhibit 13-2: A custom dialog box

Coding the Form’s Initialize Event n A form’s Initialize event occurs after the form is loaded into memory but before it is shown on the screen n In the Initialize event, you enter code that prepares the form for use 13 Exhibit 13-3: The pseudocode for the Sales Calculator form’s Initialize event

Using the Sort Method to Sort a Range n You can use the Range object’s Sort method to sort a range of values in either ascending or descending order 13 Exhibit 13-4: The basic syntax and examples of the Range object’s Sort method

Using the Sort Method to Sort a Range n You can sort a range of data based on the values stored in the one, two, or three different columns, specified in the Sort method’s Key1, Key2, and Key3 arguments n You use the Header argument, which can be set to the intrinsic constants x1Yes, x1No, or x1Guess, to specify whether the first row in the sort range contains column headers 13

The AddItem Method 13 n You use the AddItem method to specify the items you want displayed in a list box control n The AddItem method also allows you to specify the position where the new item will be placed within the control’s list n If no data appears in your list box, and the Total sales option button is not selected, close the dialog box

Examples of Using the AddItem Method 13 Exhibit 13-5: Some examples of using the AddItem method

The AddItem Method n You can use the list box’s Column Widths property, which controls the width of each column in a list box, to remove the horizontal scroll bar, and you can use either the list box’s handles or its Width property to decrease the width of the list box 13

Pseudocode for the Calculate Button’s Click Event Procedure 13 Exhibit 13-6: The pseudocode for the Calculate button’s Click event procedure

Coding the CalculateSales Macro To code the CalculateSales procedure, then test the macro: 1.Open the Project Explorer window. Open the Module1 module’s Code window, then view the code template for the CalculateSales procedure 2.Press the Tab key. Type ‘display custom dialog box and press the Enter key, then type frmsalescalc.show and press the Enter key 3.Save the workbook, then return to Excel 4.Run the CalculateSales macro. Use the Sales Calculator dialog box to calculate the total sales for salesperson 105. The label control should show the total sales are $11, Close the dialog box. Save the workbook, then exit Excel 13

Word Lesson: Viewing the Schedule Document n Before creating the custom dialog box and macro that will be used to create and print the schedule, view the document n To view the document: 1.Start Microsoft Word 2.Open the T13-WD-1 (T13-WD-1.doc) document, which is located in the Tut13\Word folder on your Data Disk. Click the Enable Macros button, if necessary, then save the document as Schedule. 13

Coding the UserForm’s Initialize Event n A form’s Initialize event occurs after the form is loaded into memory but before it is shown on the screen n In the Initialize event, you enter code that prepares the form for use 13 Exhibit 13-7: The pseudocode for the Scheduler form’s Initialize event procedure

Pseudocode for the Enter Button’s Click Event Procedure 13 Exhibit 13-8: The pseudocode for the Enter button’s Click event procedure

Coding the UserForm’s QueryClose Event n A form’s QueryClose event occurs before the form is removed from the computer’s memory, and it typically is used to perform last-minute tasks, such as verifying that the user saved the current data 13

Coding the CreateSchedule Macro n The Schedule document already contains the code template for the CreateSchedule macro procedure 13

Access Lesson: Viewing the Database n Before modifying the dialog box, view the records contained in the database’s AdjunctFaculty table n Also view a new table, named CourseNumbers, that contains the number of each CIS course 13

Modifying the Locate Button’s Click Event Procedure 13 n Before displaying the appropriate report, the Click event procedure will need to determine which option button is selected in the option group n To modify the Locate button’s Click event procedure, use the steps on pages 854 to 856 of the textbook Exhibit 13-9: The pseudocode for the Locate button’s Click event procedure

Code to Delete the cmdLocate Control’s Click Event Procedure 13 Exhibit 13-10: The code to delete in the cmdLocate control’s Click event procedure