access tutorial 11 using and writing visual basic for applications code l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Access Tutorial 11 Using and Writing Visual Basic for Applications Code PowerPoint Presentation
Download Presentation
Access Tutorial 11 Using and Writing Visual Basic for Applications Code

Loading in 2 Seconds...

play fullscreen
1 / 23

Access Tutorial 11 Using and Writing Visual Basic for Applications Code - PowerPoint PPT Presentation


  • 323 Views
  • Uploaded on

Access Tutorial 11 Using and Writing Visual Basic for Applications Code. Objectives. Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event procedure Create a function in a standard module

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Access Tutorial 11 Using and Writing Visual Basic for Applications Code' - alia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
objectives
Objectives
  • Learn about Function procedures (functions), Sub procedures (subroutines), and modules
  • Review and modify an existing subroutine in an event procedure
  • Create a function in a standard module
  • Create event procedures
  • Compile and test functions, subroutines, and event procedures
  • Hide text and change display colors
  • Create event procedures for a dialog box

New Perspectives on Microsoft Office Access 2007

introduction to visual basic for applications
Introduction to Visual Basic for Applications
  • Visual Basic for Applications (VBA) is the programming language provided with Access and other Office programs
  • VBA has a common syntax and a set of common features for all Microsoft Office programs
    • Event-driven language
    • Object-oriented language

New Perspectives on Microsoft Office Access 2007

events
Events

New Perspectives on Microsoft Office Access 2007

procedures
Procedures
  • A Function procedure,or function, performs operations, returns a value, accepts input values, and can be used in expressions (recall that an expression is a calculation resulting in a single value)
  • A Sub procedure, or subroutine, performs operations and accepts input values, but does not return a value and cannot be used in expressions

New Perspectives on Microsoft Office Access 2007

modules
Modules

New Perspectives on Microsoft Office Access 2007

modules7
Modules
  • Declarations section
  • Standard module
  • Public procedure
  • Class module
  • Local procedure
  • Private procedure

New Perspectives on Microsoft Office Access 2007

using an existing procedure
Using an Existing Procedure

New Perspectives on Microsoft Office Access 2007

creating a new standard module
Creating a New Standard Module
  • Click the Create tab on the Ribbon
  • In the Other group on the Create tab, click the arrow on the New Object button (with the ScreenTip “New Object: Macro,” “New Object: Module,” or “New Object: Class Module,” depending on which option was last chosen), and then click Module

New Perspectives on Microsoft Office Access 2007

creating a new standard module10
Creating a New Standard Module

New Perspectives on Microsoft Office Access 2007

creating a function
Creating a Function
  • Each function begins with a Function statement and ends with an End Function statement
    • Parameter
    • Argument

New Perspectives on Microsoft Office Access 2007

testing a procedure in the immediate window
Testing a Procedure in the Immediate Window
  • In the Code window, click View on the menu bar, and then click Immediate Window to open the Immediate window
  • Type a question mark (?), the procedure name, and the procedure’s arguments in parentheses. If the argument contains a string of characters, enclose the value in quotation marks
  • Press the Enter key and verify the displayed answer

New Perspectives on Microsoft Office Access 2007

testing a procedure in the immediate window13
Testing a Procedure in the Immediate Window

New Perspectives on Microsoft Office Access 2007

creating an event procedure
Creating an Event Procedure

New Perspectives on Microsoft Office Access 2007

designing the event procedure
Designing the Event Procedure

New Perspectives on Microsoft Office Access 2007

adding an event procedure to a form or report
Adding an Event Procedure to a Form or Report
  • Open the form or report in Design view, select the control whose event property you want to set, open the property sheet for the control, and then click the Event tab in the property sheet
  • Click the desired event property box, click its Build button, click Code Builder in the Choose Builder dialog box, and then click the OK button
  • Enter the subroutine statements in the Code window
  • Compile the procedure, fix any statement errors, and then save the event procedure

New Perspectives on Microsoft Office Access 2007

adding an event procedure to a form or report17
Adding an Event Procedure to a Form or Report

New Perspectives on Microsoft Office Access 2007

compiling modules
Compiling Modules
  • The process of translating modules from VBA to a form your computer understands is called compilation; you say that you compile the module when you translate it
  • When you run a procedure for the first time, Access compiles it for you automatically and opens a dialog box only when it finds syntax errors in the procedure

New Perspectives on Microsoft Office Access 2007

adding a second procedure to a class module
Adding a Second Procedure to a Class Module

New Perspectives on Microsoft Office Access 2007

adding a second procedure to a class module20
Adding a Second Procedure to a Class Module

New Perspectives on Microsoft Office Access 2007

changing the case of a field value
Changing the Case of a Field Value
  • StrConv function
  • wvProperCase constant

New Perspectives on Microsoft Office Access 2007

hiding controls and changing a control s color
Hiding Controls and Changing a Control’s Color

New Perspectives on Microsoft Office Access 2007

hiding controls and changing a control s color23
Hiding Controls and Changing a Control’s Color

New Perspectives on Microsoft Office Access 2007