I have the following which works okay...
Dim arrayTable As Variant
Dim varTable As Variant
arrayTable = Array("SG", "Oakland", "Los Angeles", "Server")
For Each varTable In arrayTable
SQL1 = "INSERT INTO tblServer ( Server, Description, [Date Audited]
) " & _
"SELECT TOP 1 Server, Description, Date() AS [Date Audited]
FROM " & varTable &";"
Next varTable
but now I need to add another array so I can change the "SELECT TOP 1"
to select different numbers. For instance ("1","2","1","5") so that SG
selects 1, Oakland selects 2, etc.
I'm still new to VBA and arrays, so is there an easy way to do this?
Thanks for any help. 2 1718
d4m wrote: I have the following which works okay...
Dim arrayTable As Variant Dim varTable As Variant
arrayTable = Array("SG", "Oakland", "Los Angeles", "Server")
For Each varTable In arrayTable
SQL1 = "INSERT INTO tblServer ( Server, Description, [Date Audited] ) " & _ "SELECT TOP 1 Server, Description, Date() AS [Date Audited] FROM " & varTable &";"
Next varTable
but now I need to add another array so I can change the "SELECT TOP 1" to select different numbers. For instance ("1","2","1","5") so that SG selects 1, Oakland selects 2, etc.
I'm still new to VBA and arrays, so is there an easy way to do this?
Thanks for any help.
Set up another array and use a for/next loop and use the counter
variable to address the index of both arrays.
<air code>
dim i as long
arrCity = Array("SG", "Oakland", "Los Angeles", "Server")
arrNum = Array("1","2","1","5")
for i = 0 to ubound(arrCity)
SQL1 = "INSERT INTO tblServer " & _
"(Server, Description, [Date Audited] " & _
"SELECT TOP " & arrNum(i) & " Server, Description, " & _
"Date() AS [Date Audited] " & _
"FROM " & arrCity(i) & ";"
next
</air code>
"d4m" <d4****@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com... I have the following which works okay...
Dim arrayTable As Variant Dim varTable As Variant
arrayTable = Array("SG", "Oakland", "Los Angeles", "Server")
For Each varTable In arrayTable
SQL1 = "INSERT INTO tblServer ( Server, Description, [Date Audited] ) " & _ "SELECT TOP 1 Server, Description, Date() AS [Date Audited] FROM " & varTable &";"
Next varTable
but now I need to add another array so I can change the "SELECT TOP 1" to select different numbers. For instance ("1","2","1","5") so that SG selects 1, Oakland selects 2, etc.
I'm still new to VBA and arrays, so is there an easy way to do this?
Thanks for any help.
rkc has provided a nice solution for you, but I am concerned about your use
of the TOP predicate. You don't have an ORDER BY clause. You won't be able
to reliably predict which 1, 2, or 5 records get selected without using
ORDER BY.
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: point |
last post by:
Hi there..
I have the folowing array
=> property = hexonet
=> property = 2003-12-01 18:46:20.0
=> property = hexonet
=> property = 2003-12-02 02:59:15.0
=> property = hexonet
=>...
|
by: Antti Nummiaho |
last post by:
Consider the following javascript:
var temp = new Array(new Array(0))
document.writeln(temp)
temp = new Array(new Array(0,1))
document.writeln(temp)
One would assume that it would print "0...
|
by: Gactimus |
last post by:
I made the program below. It outputs the smallest number in the array. What
I would like to know is how do I output the array location. I am at a loss.
For example, since the smallest number in...
|
by: ritchie |
last post by:
Hi all,
I am new to this group and I have question that you may be able to
help me with.
I am trying to learn C but am currently stuck on this.
First of all, I have a function for each sort...
|
by: ritchie |
last post by:
Hi,
I am writing to ask if anyone can see why my array is not being sorted
correctly?
It's an array of 4 elements(ints 1,2,3,4) but after calling the
selection sort
it comes back sorted as...
|
by: intrepid_dw |
last post by:
Hello, all.
I've created a C# dll that contains, among other things, two functions
dealing with byte arrays. The first is a function that returns a byte
array, and the other is intended to...
|
by: George |
last post by:
Sub ExcelToListBox()
Dim xRange As Object
Dim ary
Dim xValue As String
xRange = oXL.Range("A1:A9") 'has letters A-H
ary = xRange.value
xValue = ary(3, 1) 'xValue = C...
|
by: inkexit |
last post by:
I need help figuring out what is wrong with my code. I posted here a
few weeks ago with some code about creating self similar melodies in
music. The coding style I'm being taught is apparently a...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these...
|
by: fluk |
last post by:
Hi Guys, I hope someone can help me with this, because i'm getting
crazy to find a good way to do that!
This is what I got by querying a db.
$arr1 = array("site", "description", "area1" ,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |