How to convert Sub to a Function?

jai kushwaha

Registered User.
Local time
Today, 19:22
Joined
Nov 1, 2015
Messages
61
how I can make a macro to open run an event on a form
 
Re: Macro to open an existing form

how to convert subroutine to function?' I want to make a button on my form and want to add an event on_click. the event I want to add on click of button I made the event code but I dont know that how to convert it in function so that I can run in the macro and add it to button on_click event. so can anyone please tell me how to convert the sub code in function.????
 
Replace the word Sub with Function throughout the procedure.
 
Don't forget that a function should return a value.
I don't see why you can't add the sub to the on_click event but you probably have a good reason for that.
Here you can find some explanation about the difference : http://www.baldyweb.com/SubFunction.htm
 
There's something odd about calling functions or subs, sometimes you can't call a sub. (I might have the wrong end of the stick- Need to check when I get home) I'll put a link in when I find it.
 
I saw he mentioned macro's... I never use macro's behind buttons. I always use "Code Builder" and call my sub or function from there. Never had a problem calling subs that way...
 
how to make a code behind buttons to do event which is already an event on the form with different procedure.

explanation...
I have a form and on the form I have an event on dblclick. now I want to make a button on the same form to do the same thing on button click. now how I can do it??
 
on your buttons on click event

Call yourButtonsDouble_Click
 
if you click the code builder on the on click property in design view on your form.
 
can anyone tell me what this code mean is??DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70how I can know the number 8 mean in this code??I want full explanation of this code if anyone knows please tell me.thanks in advance....
 
thank you sir for your help can you please tell me how I can add a button on my form which will run an existing event on same form??
 

Users who are viewing this thread

Back
Top Bottom