I have the following which works okay...
Dim arrayTable As Variant
Dim varTable As Variant
arrayTable = Array("SG", "Oakland", "Server")
For Each varTable In arrayTable
SQL1 = "INSERT INTO tblServers ( Server, Description) " & _
"SELECT TOP 1 Server, Description FROM " & varTable(0) & ";"
Next varTable
But I now need to set the "SELECT TOP 1" to different numbers...so that
SG will select 1, Oakland will select 5, etc. Do I need to create
another array - if so how do I cycle through that - or is there another
way? Thanks for any help.
Steve - 09 Jan 2006 20:39 GMT
You can use a two-dimensional array to accomplish this task, if I
understand what you're trying to do.
Your array declaration would be changed to this:
Dim arrayTable (2, 1) as String
arrayTable(0, 0)="SG"
arrayTable(0, 1)="1"
arrayTable(1, 0)="Oakland"
arrayTable(1, 1)="5"
arrayTable(2,0)="Server"
arrayTable(2, 1)="3"
Then you can get those values like so:
bob=arrayTable(1,1)
So bob would now be "5".
If I've misunderstood the question, please explain a bit more.
Tom van Stiphout - 10 Jan 2006 02:23 GMT
In addition to what Steve said, here are 3 more alternatives:
1: Store this data in a table, and work with a recordset. Now the end
user or administrator can use a form to update this data, and next
time it runs the improved data will be inserted.
2: Use an array of UDT (user-defined type)
Type InsertData
strTableName as string
intTopValues as integer
End Type
dim x(2) as InsertData
x(0).strTable = "SG"
etc.
This makes the array elements self-describing, which is nice.
3: Use an array of arrays:
dim a as variant
a = Array( _
Array("SG", "1"), _
etc.
Then use a(0)(0) etc to get the data.
Choose wisely,
-Tom.
>I have the following which works okay...
>
[quoted text clipped - 14 lines]
>another array - if so how do I cycle through that - or is there another
>way? Thanks for any help.
Steve - 10 Jan 2006 14:54 GMT
>Choose wisely,
...for the fate of your database rests solely in your hands.