Global variables!

  • Thread starter Thread starter Niklas Östergren
  • Start date Start date
N

Niklas Östergren

Hi!

Do you declare your global variables in a seperat module or du you ursualy
declare them in a module which you use often in you app.?

I´m quit new to this and don´t have so much experience yet. So fare I have
declared my global variables in a module in which I have form sub´s. This
worke´s offcource, but I don´t think that it´s structured but don´t realy
know how to structure my functions and sub´s.

TIA!
// Niklas
 
There is no real hard and fast rule for this.

Some people do make a module JUST for the global vars..and thus you only
have ONE place to look for.

For me, I usually make a module called "Main". In main, I put in all global
functions, and all global variables.

I then make additional modules for grouping code. eg: MenuCode has all the
code I use for custom menus, and another one might be for my WordMerge code
etc.
 
Hi Albert!

I know that there isn´t any hard and fast rule for it. But people that have
a lot more experience then me often have found a way of doing things that
are less bad then newbee like me.

Thank´s a lot for your help. I´ll try to group my sub´s and function in some
kind of order asap.

Thanks for a quick answere!
// Niklas
 
There is no specific best practice on this, and most people set up modules
similar to the way Albert mentioned. I do that also, but occasionally modify
that structure for efficiency in my code. When you call a procedure in a
standard module, the entire module is put in memory and kept there until
that memory is needed somewhere else or you close the app. So, depending
upon what I am requiring, I may load a single variable into a single module.
An example of when would be if I was likely only to call it once in a
session. No need to load multiple variables and routines if I may use only 1
of them during a session.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Hmm, thanks for getting me to think a little bit deaper into this.

I think I need to put some effort into this. Because so far I have only
created modules for quit big tasks. Like one module for form sub´s another
for fomr functions, one for report functions and so on.

Thanks for explaining how you do!

// Niklas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top