Wiley 978-0-470-03649-5 Datenblatt

Stöbern Sie online oder laden Sie Datenblatt nach Software-Handbücher Wiley 978-0-470-03649-5 herunter. Wiley Microsoft Office Access 2007 All-in-One Desk Reference For Dummies Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 20
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 0
Chapter 1: What the Heck Is VBA?
In This Chapter
Understanding Visual Basic for Applications (VBA)
Using the Visual Basic Editor
Discovering code as you go
V
isual Basic for Applications — often abbreviated VBA — is a program-
ming language you can use to extend the functionality of Microsoft
Access and other products in the Microsoft Office suite of programs. A
pro-
gramming language
is a means of writing instructions for the computer to
execute (perform). Programmers often refer to the written instructions as
code because the instructions aren’t in plain English. Rather, they’re in a
code that the computer can interpret and execute.
You can create sophisticated Access databases without using VBA at all. In
most cases, the other objects offered by Access — tables, queries, forms,
reports, and macros — offer more than enough flexibility and power to
create just about any database imaginable. But once in a while, you come
across a situation where you want to do something that none of those other
objects can do. That’s where VBA comes in. If you can find no other way to
accomplish some goal in Access, writing code is usually the solution.
Finding VBA Code
So what the heck is VBA code, anyway? To the untrained eye, VBA code
looks like gibberish — perhaps some secret code written by aliens from
another planet. But to Access, the code represents very specific instruc-
tions on how to perform some task.
Within any given database, Access stores code in two places:
Class modules (Code-Behind Forms): Every form and report you create
automatically contains a
class module (also called a code-behind form),
as illustrated in Figure 1-1. The class module for a given form or report
is empty unless you place controls that require VBA code on that form
or report.
38_036494 bk08ch01.qxp 11/17/06 8:34 AM Page 571
COPYRIGHTED MATERIAL
Seitenansicht 0
1 2 3 4 5 6 ... 19 20

Inhaltsverzeichnis

Seite 1 - COPYRIGHTED MATERIAL

Chapter 1: What the Heck Is VBA?In This Chapter Understanding Visual Basic for Applications (VBA) Using the Visual Basic Editor Discovering code as

Seite 2 - Opening a class module

Using the Visual Basic Editor580✦ Split bar: This divvies up the screen for you. Drag the Split bar down toseparate the Code window into two independe

Seite 3 - Finding VBA Code

Book VIIIChapter 1What the HeckIs VBA?Using the Visual Basic Editor581When the Immediate window is open, you can anchor it to the bottom of theVisual

Seite 4

Using the Visual Basic Editor582Do bear in mind that the Immediate window is just for testing and debug-ging. The Code window is where you type (or pa

Seite 5 - Enabling VBA Code

Book VIIIChapter 1What the HeckIs VBA?Using the Visual Basic Editor583✦ Project/Library list: This allows you to choose a single library or proj-ect t

Seite 6

Using the Visual Basic Editor584You can search the Object Library for information about any object, includ-ing DoCmd, by following these steps:1. In t

Seite 7 - Talkin’ the talk

Book VIIIChapter 1What the HeckIs VBA?Using the Visual Basic Editor585Referring to objects and collectionsObjects in the object model all have a synta

Seite 8

Using the Visual Basic Editor586At the risk of confusing matters, typing the following line in the Immediatewindow returns the same result:? CurrentPr

Seite 9 - Using the Code window

Book VIIIChapter 1What the HeckIs VBA?Discovering Code as You Go587Closing the Visual Basic EditorWhen you’re done working in the Visual Basic Editor,

Seite 10 - Using the Immediate window

Discovering Code as You Go588When you convert a macro to VBA code, you actually convert all the macrosin the macro group to code. Follow these steps f

Seite 11 - Using the Visual Basic Editor

Book VIIIChapter 1What the HeckIs VBA?Discovering Code as You Go589A dialog box appears, asking whether you want to include error-handlingcode or comm

Seite 12 - Using the Object Browser

Finding VBA Code572✦ Standard modules: Code can also be stored in standard modules. Code instandard modules is accessible to all objects in your datab

Seite 13 - Searching the Object Library

Discovering Code as You Go590Cutting and pasting codeMany VBA programmers post examples of code they’ve written on Webpages. When you come across some

Seite 14 - Search results

Book VIIIChapter 1What the HeckIs VBA?Finding VBA Code573You can also get to a class module from the Event tab of the Property sheetin the Design View

Seite 15

Finding VBA Code574To create a new module, click the Create tab. Then click the arrow under theMacros button and choose Module (Figure 1-4). The Visua

Seite 16 - Choosing object libraries

Book VIIIChapter 1What the HeckIs VBA?Enabling VBA Code575Enabling VBA CodeLike any programming language, people can use VBA to create code thatdoes g

Seite 17 - Discovering Code as You Go

Using the Visual Basic Editor576Procedures in a module fall into two major categories: sub procedures andfunction procedures. Both types of procedures

Seite 18 - TinyMacro

Book VIIIChapter 1What the HeckIs VBA?Using the Visual Basic Editor577you click outside the Visual Basic Editor window, the window may disappearas wha

Seite 19 - Converted

Using the Visual Basic Editor578The Visual Basic Editor provides many tools designed to help you writecode. Most of the tools are optional and can be

Seite 20 - Cutting and pasting code

Book VIIIChapter 1What the HeckIs VBA?Using the Visual Basic Editor579Using the Code windowThe Code window is where you type your VBA code. Similar to

Kommentare zu diesen Handbüchern

Keine Kommentare