PDA

Click to See Complete Forum and Search --> : RUN Module RUN! [RESOLVED]


mr_tango
Apr 22nd, 2004, 04:27 AM
Hi all,

I have got a module that I can run from MS Access. At the moment the user is required to go into the VB editor and run the code from there. Obviously this is quite pants, so I was hoping to create a "run button" which the user could just click from the normal Access control panel thing, (tables, queries, macros, modules pane thing...). Doe anyone know how to do this?


Cheers

alex_read
Apr 22nd, 2004, 04:38 AM
Follow these steps & it'll give you an idea of how to do this:

1) Go into modules in your access database, hit the new button, then type this in & save the module as module1 (note that this method has been declared with the Public keyword so as any forms etc. in the database will be able to call upon it):
Public Sub ShowMsg()
MsgBox "Hello World!"
End Sub

2) Go into forms in the same database, click onto the "create form in design view" option - you should now see a blank form ready for designing.

3) Goto the view menu > toolbox & draw a button on the form then click onto the cancel button when the wizard shows. Right click this button & go into properties option at the bottom of this popup menu.

4) Under the event tab, click the OnClick textbox once & an ellipsis (...) button will appear to the right of this. Click this & choose the code builder option.

5) in the code module, make the code look like this, then save all the forms & code & close them down.
Private Sub Command0_Click()
Module1.ShowMsg
End Sub

Start up the form & this'll call out the module's procedure...

mr_tango
Apr 22nd, 2004, 05:02 AM
Top Job! Thanks for the help, it works like a charm.