Search code examples
ms-accessvba

How to execute VBA Access module?


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!


Solution

  • 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.