stupid question - call code (1 Viewer)

Lanason

Registered User.
Local time
Today, 04:44
Joined
Sep 12, 2003
Messages
258
this is basic I know but I have never done it

I have a piece of code I want to repeat many times
rather than enter in every files / form

how/ where do I store it and how do I call it

is it a module?
if so is public sub / public function the right way?

a quick over view of this would be great please -
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 23:44
Joined
Jan 23, 2006
Messages
15,394
I have a piece of code I want to repeat many times
rather than enter in every files / form

Sounds like a public Function --if it returns some value.
If it does not return a value, then a public Sub would seem ok.

It would reside in a Standard module.

See this info from Paul (BaldyWeb) for more
 
Last edited:

MarkK

bit cruncher
Local time
Yesterday, 20:44
Joined
Mar 17, 2004
Messages
8,186
...how/ where do I store it and how do I call it...
My 2c, in general, if you are asking a question about code, show the code. Code speaks for itself, and then we can give you way more precise information.
hth
Mark
 

breakingme10

New member
Local time
Yesterday, 22:44
Joined
Apr 18, 2014
Messages
5
Once you put it in a module, you can use a button or event on the form to call it using

Call 'Name' in the on click event of the button, or any event that works for what your are trying to do.
 

Mark_

Longboard on the internet
Local time
Yesterday, 20:44
Joined
Sep 12, 2017
Messages
2,111
2nd to Mark's 2c...

Can you explain what you are trying to do. In some cases it makes perfect sense to have a globally available piece of code. In others, having it inside a procedure (but keeping to a naming convention you fine useful) works better.
 

Users who are viewing this thread

Top Bottom