Global Dims and Strings

L

Lillian

Can Dims and Strings be made for global access by private subs?
If so how can I do this?

What I am asking for can I set up my set of dims and set strings and
then make event procedures that use them instead of making many of these
same dims over and over again. I would think this would save much time.

example of a global Dims
Dim iCol As Long
Dim Col_id As String
Dim colRange As Range

iCol = such and such
 
L

Lillian

Douglas said:
You can put your declarations into a module (not a class module, nor a
module associated with a form or report), and the variables will be
available to all other modules in the application. However, it's generally
not considered to be a good idea to use global variables. If you really
want to avoid typing, you can always copy-and-paste the declarations from
one routine to another.


I put my Dims under the Option Compare Database
and before the first Private Sub.

It is working.

I don't know of a problem doing it this way. It is working.
It is not a large amount of Dims less than 20.
 
B

Bob Quintal

Can Dims and Strings be made for global access by private subs?
If so how can I do this?

What I am asking for can I set up my set of dims and set strings
and then make event procedures that use them instead of making
many of these same dims over and over again. I would think this
would save much time.

example of a global Dims
Dim iCol As Long
Dim Col_id As String
Dim colRange As Range

iCol = such and such
Save much time? Pardon my snickering.... any time you save coding
will be lost ten-fold trying to debug why you've deleted the wrong
record because another procedure has changed your variable.

To declare your variables as public, code a procedure that you can
run at database startup, that contains the following

Public iCol as long
Public Col_ID as string
Dim colRange as Range
 
D

Douglas J. Steele

You can put your declarations into a module (not a class module, nor a
module associated with a form or report), and the variables will be
available to all other modules in the application. However, it's generally
not considered to be a good idea to use global variables. If you really want
to avoid typing, you can always copy-and-paste the declarations from one
routine to another.
 

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

Top