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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i execute a module from a form (i.e. main menu)?

Status
Not open for further replies.

marnold37341

Programmer
Mar 4, 2002
7
US
I have a module that I want to run from the main menu when a button is clicked. I understand I can include the vb code in the area for button_Click, but I prefer to keep the code in the module. Someone said I merely have to put the module name in the button_Click Sub, but I get compiler error(s) when doing that. Any help or suggestions?

Mickey Arnold
marnold37341@yahoo.com
 
in the button code type CALL MODULENAME.FUNCTIONNName

by typing the module name, the intellisense boxes will show the various components of the module...

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Hi Mickey!

Just to be clear, I am going to assume that by module you mean a function or procedure in a module, if not, then you need to call it by the procedure name not the module name. That said, I usually use the keyword Call before the procedure name, but that shouldn't be your problem. When you get your error click debug to see where the compile error is(if you have already done this let us know where the compile error is). If the error occurs on the line where you call the function then check the spelling of the function name and make sure the function is public(although these two things should give you a different error). Make sure that you are sending the function all of the parameters it needs(again a different error should occur). Make the sure the function doesn't have the same name as another object in your database as this could easily confuse Access. Finally, you can try going to the buttons property window and click on the Event tab. In the OnClick line type: =YourFunctionName(). For this to work, you must make it a public Function in a module.

If none of this works then repost with the code of the function and we can see if there is a problem there.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Micky, also, make sure the procedure or function actually WORKS as well - in the code editing window, press F5 to "run" the code. Or click the COMPILE button. Whatever. You need to make sure the code itself works, before you go and call it from the form. Otherwise, you won't really know if your "error" is on the form end or the code end.

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top