Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a module from a form

Status
Not open for further replies.

boettger

Programmer
Sep 27, 2000
15
US
I have a VB module that I wrote to update a total table from another table. It works great and since I'm very new to Access I'm pleased. I'm trying to just click a button
on a form and run the VB module. I've tried creating a macro to execute
the module but I get an access error saying it can't find it. I've looked thru the forum
and tried some of the answers but I can't get it to work. Again when I run the VB module it works just great. Is there something basic that I'm overlooking like a path statement? Any help would be great.
 
You need to go into the properties of the button, click on the 'event' tab, select 'event procedure' next to the 'on click' event. Then click on the '...' , which will take you to the vb modules for the form. In the 'on click' module for the button, type

Call yourmodulename()



Mike Rohde
rohdem@marshallengines.com
 
Thanks for your answer. When I tried what you said ,it seems like the module that I wrote is not attached to the form. I created the module (it's a sub function) before I created the form.
How do I attach the module to the form??? I'll keep working on it but any more help would be great.


Thanks
Pat
 
I am a little confused as to where the code that you wrote is actually at. Did you go to the database window, click on modules, click new, and then type your code? If this is the case, then if you declared the function as a public function, you should be able to call it from any module.

Another option would be to just paste the code above or below the 'on click' procedure for the button. Then place the command

call functionname()

in the 'on click' procedure for the button.

A third option would be to just paste your code into the 'on click' event for the button.

Good Luck!



Mike Rohde
rohdem@marshallengines.com
 
Thank you so much. I just pasted the code and it's works.

Thanks again Pat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top