VBScript Tutorials - Herong's Tutorial Examples - v6.02, by Herong Yang
Using Visual Basic with Microsoft Access
This section provides tutorial example on how to add a Visual Basic code in Microsoft Access database to be executed as a macro on database tables.
As a comparison, this tutorial shows you how to write Visual Basic for Application (VBA) code and run it as a macro with Microsoft Access.
Microsoft Access is a Microsoft application that can be used to store and manage data in database tables. Microsoft Access also supports a macro module that allows you to write macro code with VBA language.
If you have Microsoft Access installed on your Windows system, you can follow the steps below to create a simple application in VBA within Microsoft Access.
1. Run Microsoft Access, and create a blank Access Database called vb_tutorial.mdb.
2. Click Insert > Module from the menu. The Microsoft Visual Basic window shows up.
3. Enter the following code into the empty code module:
Sub Main() MsgBox ("Hello world! - VBA in Access") End Sub
4. Click File > Save from the menu. Enter "Hello" as the module name and save it.
5. Click Run > Run Sub/UserForm from the menu. The macro selection dialog box shows up.
6. Select "Main" macro, and click "Run". A dialog box shows up with the following message:
Hello world! - VBA in Access
Congratulations. You have successfully written a VBA macro in Microsoft Access!
What happened here was:
Table of Contents
►Introduction of VBScript - Visual Basic Scripting Edition
Using VBScript with Internet Explorer 10 or Older
Using VBScript with Internet Explorer 11
Using VBScript with Internet Information Services
Using VBScript with WSH (Windows Script Host)
►Using Visual Basic with Microsoft Access
VBScript and Supporting Environments
Variant Data Type, Subtypes, and Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
IE Web Browser Supporting VBScript