VBScript Tutorials - Herong's Tutorial Examples - Version 5.24, by Dr. 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 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 Visual Basic (VB) language.
If you have Microsoft Access installed on your Windows system, you can follow the steps below to create a simple application in Visual Basic language 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! - Visual Basic 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! - Visual Basic in Access
Congratulations. You have successfully written a Visual Basic macro in Microsoft Access!
What happened here was:
Table of Contents