Wordware, Access 2003 Programming By Example With Vba Xml And Asp (2005) Ddu Lotb.pdf

(11898 KB) Pobierz
Access 2003 Programming by Example with VBA, XML, and ASP
254332342.002.png
Access 2003
Programming by
Example with VBA,
XML, and ASP
Julitta Korol
Wordware Publishing, Inc.
254332342.003.png
Library of Congress Cataloging-in-Publication Data
Korol, Julitta.
Access 2003 programming by example with VBA, XML, and ASP / by Julitta Korol.
p. cm.
Includes index.
ISBN-13: 978-1-55622-223-8
ISBN-10: 1-55622-223-8 (pbk.)
1. Microsoft Access. 2. Database management. I. Title.
QA76.9.D3K6573 2005
005.75'65--dc22
2004030068
CIP
© 2005, Wordware Publishing, Inc.
All Rights Reserved
2320 Los Rios Boulevard
Plano, Texas 75074
No part of this book may be reproduced in any form or by
any means without permission in writing from
Wordware Publishing, Inc.
Printed in the United States of America
ISBN-13: 978-1-55622-223-8
ISBN-10: 1-55622-223-8
10987654321
0501
All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any
omission or misuse (of any kind) of service marks or trademarks should not be regarded as intent to infringe on the property of
others. The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to
distinguish their products.
This book is sold as is, without warranty of any kind, either express or implied, respecting the contents of this book and any disks
or programs that may accompany it, including but not limited to implied warranties for the book’s quality, performance,
merchantability, or fitness for any particular purpose. Neither Wordware Publishing, Inc. nor its dealers or distributors shall be
liable to the purchaser or any other person or entity with respect to any liability, loss, or damage caused or alleged to have been
caused directly or indirectly by this book.
All inquiries for volume purchases of this book should be addressed toWordware Publishing, Inc.,
at the above address. Telephone inquiries may be made by calling:
(972) 423-0090
254332342.004.png
Contents
Acknowledgments .....................................xiv
Introduction ........................................xv
Part I — Introduction to Access 2003 VBA Programming
Procedures and Modules ........................3
Procedure Types .......................................3
Module Types ........................................4
Events, Event Properties, and Event Procedures ......................6
Why Use Events?...................................7
Walking Through an Event Procedure ........................7
Compiling Your Procedures .............................11
Chapter Summary .....................................11
The Visual Basic Editor (VBE) ......................12
Understanding the Project Explorer Window .......................12
Understanding the Properties Window ...........................13
Understanding the Code Window .............................14
Other Windows in the VBE ................................16
On-the-Fly Syntax and Programming Assistance .....................16
List Properties/Methods ...............................17
Parameter Info ...................................18
List Constants ....................................19
Quick Info ......................................19
Complete Word ...................................20
Indent/Outdent ...................................20
Comment Block/Uncomment Block ........................21
Using the Object Browser .................................22
Using the VBA Object Library...............................24
Using the Immediate Window ...............................25
Chapter Summary .....................................27
Chapter 3 Variables, Data Types, and Constants .................28
What Is a Variable?.....................................28
What Are Data Types? ...................................29
Creating Variables .....................................30
Declaring Variables ....................................31
Specifying the Data Type of a Variable ..........................33
Using Type Declaration Characters ............................35
Assigning Values to Variables ...............................36
iii
Chapter 1
Chapter 2
254332342.005.png
iv | Contents
Forcing Declaration of Variables ..............................38
Understanding the Scope and Lifetime of Variables ....................40
Procedure-Level (Local) Variables .........................40
Module-Level Variables...............................41
Public Variables ...................................42
Understanding and Using Static Variables .........................43
Declaring and Using Object Variables ...........................45
Finding a Variable Definition ...............................47
What Type Is This Variable? ................................47
Using Constants in VBA Procedures............................48
Intrinsic Constants .....................................49
Chapter Summary .....................................51
Passing Arguments to Procedures and Functions ............52
Writing a Function Procedure ...............................52
Specifying the Data Type for a Function’s Result .....................54
Passing Arguments by Reference and by Value ......................56
Using Optional Arguments .................................57
Using the IsMissing Function ...............................59
Built-in Functions .....................................59
Using the MsgBox Function ................................59
Returning Values from the MsgBox Function....................66
Using the InputBox Function................................67
Converting Data Types ...................................69
Using Master Procedures and Subprocedures .......................71
Chapter Summary .....................................75
Chapter 5 Decision Making with VBA.......................76
If…Then Statement ....................................77
Multi-Line If…Then Statement ..............................78
Decisions Based on More Than One Condition ......................80
If…Then…Else Statement .................................81
If…Then…ElseIf Statement ................................83
Nested If…Then Statements ................................84
Select Case Statement ...................................85
Using Is with the Case Clause............................88
Specifying a Range of Values in a Case Clause ...................88
Specifying Multiple Expressions in a Case Clause .................90
Chapter Summary .....................................90
Repeating Actions in VBA .......................91
Using the Do…While Loop ................................91
Another Approach to the Do…While Loop ........................93
Using the Do…Until Loop .................................94
Another Approach to the Do…Until Loop .........................95
For…Next Loop ......................................96
For Each…Next Loop ...................................98
Exiting Loops Early ....................................99
Nested Loops ........................................99
Chapter Summary .....................................101
Chapter 4
Chapter 6
254332342.001.png
Zgłoś jeśli naruszono regulamin