sub5
Programmer
- Oct 12, 2005
- 104
Hello all,
How do I test that a multidimensional array has nothing in it? This is my code and process:
A form is opened. The following is declared at the form module level.
Private marr1() as variant
Private mintrows as integer
The form on open event includes:
mintrows = -1
The user selects an item from cbo1 and clicks cmd1 which runs this code:
mintrows = mintrows + 1
redim preserve marr1(0,mintrows)
marr1(0,mintrows) = me!cbo1
The SQL rowsource of ctl1 is modified so that the selected item drops off the list.
The user then selects another item from cbo1 and clicks cmd1 again.
They can cycle through like this until not items remain in cbo1's dropdown list.
First I wanted to get rid of the need for mintrows by using this code but I get runtime error 9; subscript out of range:
dim upper as integer
upper = ubound(marr1,2)
(nb also tried ubound(marr1) and ubound(marr1,0) and ubound(marr1,1))
redim preserve marr1(0,upper)
marr1(0,upper) = me!cbo1
I also tried to make it so that the first time round the code checks to see if the variable has not been initialised / is empty / null / blank but it always thinks there is something there:
if isempty(marr1) = true then
redim preserve marrrateid(0,0)
marr1(0,0) = me!cbo1
else
Dim upper as integer
upper = ubound(marr1,2)
redim preserve marr1(0,upper)
marr1(0,upper) = me!cbo1
end if
Instead of isempty I have also tried isnull, trim([marr1] & "") = "", marr1 =/is/like "".
Any ideas?
How do I test that a multidimensional array has nothing in it? This is my code and process:
A form is opened. The following is declared at the form module level.
Private marr1() as variant
Private mintrows as integer
The form on open event includes:
mintrows = -1
The user selects an item from cbo1 and clicks cmd1 which runs this code:
mintrows = mintrows + 1
redim preserve marr1(0,mintrows)
marr1(0,mintrows) = me!cbo1
The SQL rowsource of ctl1 is modified so that the selected item drops off the list.
The user then selects another item from cbo1 and clicks cmd1 again.
They can cycle through like this until not items remain in cbo1's dropdown list.
First I wanted to get rid of the need for mintrows by using this code but I get runtime error 9; subscript out of range:
dim upper as integer
upper = ubound(marr1,2)
(nb also tried ubound(marr1) and ubound(marr1,0) and ubound(marr1,1))
redim preserve marr1(0,upper)
marr1(0,upper) = me!cbo1
I also tried to make it so that the first time round the code checks to see if the variable has not been initialised / is empty / null / blank but it always thinks there is something there:
if isempty(marr1) = true then
redim preserve marrrateid(0,0)
marr1(0,0) = me!cbo1
else
Dim upper as integer
upper = ubound(marr1,2)
redim preserve marr1(0,upper)
marr1(0,upper) = me!cbo1
end if
Instead of isempty I have also tried isnull, trim([marr1] & "") = "", marr1 =/is/like "".
Any ideas?