Hi all,
I am trying to dynamically fill an array with any unique values from a field
(objRS.Fields(5)) in my database with the following code below. However it
errors with "The array is fixed or temporarily blocked" for the line "REDIM
PRESERVE UserArray(Arraycount+1)". I can't seem to get around this. Any
suggestions? Many thanks.
Dim p
Dim UserArray(0) ' Max number of users
Dim Arraycount
Dim flag
objRS.MoveFirst
Do While Not objRS.EOF
p = 0
flag = false
'--Check if username is already in the array
Arraycount = UBound(UserArray)
do while (p <= Arraycount) And (flag = false)
if objRS.Fields(5) = UserArray(p) then flag = true
P=P+1
loop
if (flag = false) then ' name not in array
UserArray(Arraycount) = objRS.Fields(5)
REDIM PRESERVE UserArray(Arraycount+1)
End if
objRS.MoveNext
Loop