Access VBA Fundamentals - Access All In One

VBA Made Easy

Access VBA

Fundamentals

Level 3



This guide was prepared for by:

Robert Austin

This is one of a series of guides pertaining to the use of Microsoft Access.

? AXLSolutions 2012

All rights reserved. No part of this work may be reproduced in any form, or by any means,

without permission in writing.

1|Page

Contents

05 - Functions, Sub Procedures And Arguments ...................................................................... 5

VBA Language in Context ...................................................................................................... 5

What is a Sub Procedure? ...................................................................................................... 5

What is a Function? ............................................................................................................... 6

Calling Sub Procedures And Functions From The Immediate Window................................ 6

Calling Sub Procedures from other Sub Procedures ..............................................................8

Calling Functions ................................................................................................................... 9

Built-in Functions ................................................................................................................ 10

Using Expression Builder ................................................................................................. 10

Commonly Used and Useful Built-In Functions .................................................................. 13

String Functions ............................................................................................................... 13

Conversion ........................................................................................................................ 13

Date and Time Functions ................................................................................................. 14

Is Functions ...................................................................................................................... 15

Custom Functions And Sub Procedures .............................................................................. 18

Anatomy of a Sub Procedure ............................................................................................ 19

Anatomy of a Function ..................................................................................................... 21

Declaring Functions and Procedures ................................................................................... 22

Scope................................................................................................................................. 22

Declarations in a Module and Global Scope (and a little private-cy)............................... 22

Declarations in a Form or Report Modules ...................................................................... 25

Exercises............................................................................................................................... 26

Answers ................................................................................................................................ 47

06 ¨C Debugging........................................................................................................................30

Learning Outcomes ..................................................... Error! Bookmark not defined.

Break on Unhandled Errors .................................................................................................30

Breakpoints .......................................................................................................................... 32

Debug Control Bar ............................................................................................................... 33

Immediate Window.............................................................................................................. 34

? and Debug.Print ............................................................................................................. 34

: to concatenate commands .............................................................................................. 34

; to concatenate strings ..................................................................................................... 34

Note .................................................................................................................................. 34

Call a Procedure................................................................................................................ 35

Immediate Window is in Scope ........................................................................................ 35

2|Page

Code Window Pop-ups ......................................................................................................... 36

Watches Window.................................................................................................................. 37

VBE Editor Options ..............................................................................................................38

Compilation Explained ....................................................................................................... 40

Advanced Compilation and ACCDE .................................................................................... 40

ACCDE files ................................................................. Error! Bookmark not defined.

Why use an ACCDE file?................................................................................................... 42

Multi-Users Environments .................................................................................................. 42

Questions.............................................................................................................................. 44

3|Page

4|Page

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download