ease20022002
Board Regular
- Joined
- Jun 4, 2005
- Messages
- 233
Hello,
I am populating an array as follows and I don't want to change the way I am populating the array. I am in VB 6.0. Here is the variable array I am populating:
When the array is populated it doesn't appear to be a 2 dimensional array (multidimensional). I have tried diming the array as varTable(0 to 1, 0 to 1), but then I can't populate the varTable variable with the preceding code syntax. When I redim varTable to
it becomes a 2 dimensional array (multidimensional) so I see in the Locals Window varTable (0 to 1, 0 to 1) , but once I populate the array with the previous code syntax (1st code syntax), in the Locals Window it goes back to a 1 dimensional, varTable(0 to 1) but the variable has all the values as the two dimensional variable has. Meaning in the Locals Window I see the varTable (0 to 1), but when I drill into the variable, I see (0, 0) = "LossCentral", (0, 1) = "PremCentral", (1, 0) = "LossArchive" and (1, 1) = "PremArchive".
This variable fits into an SQL statement with other 1 dimensional variable arrays and some variables. I need varTable to be multidimensional. Here is the SQL that the varTable fits into:
There is more SQL but the basics are there.
I guess the question is, how do I loop through a dimensionalized array that appears to be 1 dimension, but infact is two dimesions. I get the subscript is out of range when I run. I.e., I have tried looping through varTable by using: varTable(x,(x,y)), etc., and I can't figure it out. Maybe I can't dimensionalize an array like I did and loop through it. That is all I am trying to do. Loop through varTable when populating the array like I did in the first original syntax that I posted. I also do not want to dimensionalize the array by using something like the following if I don't have to:
Thanks for any help.
I am populating an array as follows and I don't want to change the way I am populating the array. I am in VB 6.0. Here is the variable array I am populating:
Code:
varTable = Array(Array("LossCentral", "PremCentral"), Array("LossArchive", "PremArchive"))
When the array is populated it doesn't appear to be a 2 dimensional array (multidimensional). I have tried diming the array as varTable(0 to 1, 0 to 1), but then I can't populate the varTable variable with the preceding code syntax. When I redim varTable to
Code:
ReDim varTable(UBound(Array("LossCentral", "PremCentral")), UBound(Array("LossArchive", "PremArchive")))
it becomes a 2 dimensional array (multidimensional) so I see in the Locals Window varTable (0 to 1, 0 to 1) , but once I populate the array with the previous code syntax (1st code syntax), in the Locals Window it goes back to a 1 dimensional, varTable(0 to 1) but the variable has all the values as the two dimensional variable has. Meaning in the Locals Window I see the varTable (0 to 1), but when I drill into the variable, I see (0, 0) = "LossCentral", (0, 1) = "PremCentral", (1, 0) = "LossArchive" and (1, 1) = "PremArchive".
This variable fits into an SQL statement with other 1 dimensional variable arrays and some variables. I need varTable to be multidimensional. Here is the SQL that the varTable fits into:
Code:
For x = 0 To UBound(varDatabase) ' nested looping mechanism to assure that both loss and prem tables are deleted from each DB
For y = 0 To UBound(varTable)
strSQL = "DELETE * FROM " & varTable(x, y) & " IN '" & varDatabase(x) & "';
DoCmd.RunSQL (strSQL) ' runs SQL
Next y
Next x
There is more SQL but the basics are there.
I guess the question is, how do I loop through a dimensionalized array that appears to be 1 dimension, but infact is two dimesions. I get the subscript is out of range when I run. I.e., I have tried looping through varTable by using: varTable(x,(x,y)), etc., and I can't figure it out. Maybe I can't dimensionalize an array like I did and loop through it. That is all I am trying to do. Loop through varTable when populating the array like I did in the first original syntax that I posted. I also do not want to dimensionalize the array by using something like the following if I don't have to:
Code:
varTable(0, 0) = LossCentral
varTable(0, 1) = PremCentral
varTable(1, 0) = LossArchive
varTable(1, 1) = PremArchive
Thanks for any help.