The Function Template Wizard

Larry W Jordan Jr.
Derik Harris
Microsoft Corporation

Created: July 15, 1996
Revised: August 7, 1996

Larry W Jordan Jr. is a Senior Microsoft Access support engineer. His main focus is VBA, wizard and add-in development and Visual SourceSafe integration.

Derik Harris is a Senior Microsoft Access content engineer.  His primary responsibility is writing, editing, and publishing Microsoft Access related material for the Microsoft Knowledge Base and the Microsoft Web site.

Click to open or copy the FUNCWIZ project files.

Overview

The Function Template Wizard provides a simple tool to create skeleton routines for use in Visual Basic for Applications. The premise of the wizard assumes that every routine that you create in Visual Basic for Applications has some basic, intrinsic elements that include error trapping and/or data access object (DAO) access code. The wizard can create the following sample syntax with a button click:

Public Function TestFunction1() As Variant

   Dim Msg As String ' for error handling

   On Local Error GoTo TestFunction1_Err
   TestFunction1 = True

TestFunction1_End:
   Exit Function

TestFunction1_Err:
   Msg = "Error #: " & Format$(Err.Number) & vbCrLf
   Msg = Msg & Err.Description
   MsgBox Msg
   Resume TestFunction1_End
End Function

Introduction

The Function Template Wizard provides a simple tool to create skeleton routines for use in Visual Basic for Applications. The premise of the wizard assumes that every routine that you create in Visual Basic for Applications, has some basic intrinsic elements that include error trapping and/or DAO access code.

The Wizard supports the following features:

  1. Create a Sub routine or function.

  2. Create Public or Private statements.

  3. Set the return data type of the function (such as As string, As Boolean, and so on.)

  4. Include error handling.

  5. Include most, common data access objects (DAO) code.

  6. Insert into specific database module.

  7. Alternately copies the routine to the operating system Clipboard.

  8. Display Debug window for testing.