New to using Arrays

BCNicki

New member
Local time
Today, 14:42
Joined
Jan 2, 2013
Messages
6
I've created an array that I created and declared as a Public array in my module. I created a function that populates the array so that I can use the values in another function. I've gotten the array to populate but when I go to use the values in the array in another function, the array appears at Empty. I seem to be stuck on declaring it properly or something so that it can be used by other functions. Any words of wisdom?

Public arrWebIDs As String

Public Function FillArray()
 
Did you put the declaration of the array into a Standard Module and not a form, report, or class module? If not you need to do so.
 
I'm reposting above with the missing details. Sorry I somehow hit Post before I was done typing.

I've created an array that I created and declared as a Public array in my module. I created a function that populates the array so that I can use the values in another function. I've gotten the array to populate but when I go to use the values in the array in another function, the array appears at Empty. I seem to be stuck on declaring it properly or something so that it can be used by other functions. Any words of wisdom? The basics of my code are below!

===========
Public arrWebIDs As String
===========
Public Function FillArray()
ReDim arrWebIDs(0 to 3)
Dim i as Byte
Do Until rst.eof
arrWebIDs(i) = rst!webID
i=i+1
rst.movenext
Loop
 
Hi SOS,
I've added this to a Standard Module - not a form, report or otherwise. Thanks for asking.
 
One thing I did notice is you are missing that it is an array:

Public arrWebIDs As String

Should be

Public arrWebIDs() As String
 
I've added the () so now my statement is correct. I can't believe I missed that!
I am now getting "Run-time error '9': Subscript out of range" when I try to use:

for i = 1 to UBound(arrWebIds) in the function where I am trying to call the values out of the array from.
 
Found the error in my code. I dropped the 's' in the array name in part of my code! My eyes are getting too tired for this. Time to pack it in for the day. Thanks for your help!
 

Users who are viewing this thread

Back
Top Bottom