Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute VBA Access module?

Tags:

vba

ms-access

Ok I'm using Access 2003 and I've just started learning Access and VBA a few days ago.
I wrote some code in a module and there are no errors when I press the play button on the debugger toolbar up top.
How do I actually execute this code on my database so that it will do something.
In other words how do I make use of the module?

Please help me out I'm struggling hard and the deadline for this is thursday!

Thanks!

like image 682
Shubham Avatar asked Jul 19 '11 23:07

Shubham


People also ask

How do I Access VBA in Access?

All VBA code in your Microsoft Access VBA programming environment is managed in an area known as the Visual Basic Editor (VBE) and can be accessible via a form, report or quickly by using the Alt + F11 function key from the keyboard.

What is a VBA module in Access?

A module is a collection of user-defined functions, subroutines, and global variables written in VBA code. These objects can then be used/called from anywhere in your Access database.


1 Answers

Well it depends on how you want to call this code.

Are you calling it from a button click on a form, if so then on the properties for the button on form, go to the Event tab, then On Click item, select [Event Procedure]. This will open the VBA code window for that button. You would then call your Module.Routine and then this would trigger when you click the button.

Similar to this:

Private Sub Command1426_Click()
    mdl_ExportMorning.ExportMorning
End Sub

This button click event calls the Module mdl_ExportMorning and the Public Sub ExportMorning.

like image 66
Taryn Avatar answered Oct 29 '22 01:10

Taryn