Using a Public Array

G

Guest

I would like to populate an array from a form event, and use the array from
other procedures of the same form. I can't declare the array as public at
the module level, however. Can I make an array accessible to all procedures
in a module?
 
D

Douglas J. Steele

Declare the array in a module (not a class module nor the module associated
with any form or report)
 
D

Douglas J. Steele

Because what's declared in a form's module is local to that form only.

You can refer to the form to get at public variables defined in the form:

Form_NameOfForm.Array

or

Forms("NameOfForm").Array

However, that only works while the form's open. If you close the form, all
variables disappear.
 
D

David W. Fenton

Because what's declared in a form's module is local to that form
only.

You can refer to the form to get at public variables defined in
the form:

Form_NameOfForm.Array

or

Forms("NameOfForm").Array

However, that only works while the form's open. If you close the
form, all variables disappear.

And you can't do it for arrays, which cannot be a public member of
any kind of class module (including form modules).
 

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

Similar Threads

Public Dynamic Arrays 6
Array basics! 3
Global Array in User Form 1
Shape Arrays VBA 0
Excel Wildcard in Excel array formula 0
Create array of C# procedures? 9
Public array 1
Load a range into an array for Userforms 0

Top