Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm trying to read data from a worksheet, inputting it into an array, and make SQL queries based on the array value, repeat for each value. I'm having problems getting the array value into the query though. Heres example code: Sub Pass_array() Dim myarray As Variant myarray = Range("C15:C18").Value receive_array myarray End Sub --- Sub receive_array(thisarray) Dim dbConn2 As New ADODB.Connection Dim rs2 As New ADODB.Recordset 'the recordset dbConn2.ConnectionString = (connection string here, works fine) dbConn2.Open For i = 1 To UBound(thisarray) MsgBox thisarray(i, 1) *** <-- this is my check to see what value is getting put in With rs2 ..Open "SELECT DISTINCT PRICING.PRICE FROM MAIN, PRICING WHERE (MAIN.SERIES LIKE 'A123') AND (PRICING.TYPE = 'D') AND (MAIN.ID = PRICING.PART_ID) AND (PRICING.START=thisarray(i,1)", dbConn2, adOpenStatic noRecords = .RecordCount Range("F15").CopyFromRecordset rs .Close End With Next dbConn.Close End Sub If I do this, it says thisarray is not a function. If I just input i, it says invalid column name. Any help is appreciated thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to import web query as array? | Excel Discussion (Misc queries) | |||
Array formulas won't recognize external data from Microsoft Query | Excel Discussion (Misc queries) | |||
SQL Query Destination as an array varable | Excel Programming | |||
Web Query & Array Questions! | Excel Programming | |||
Query for data in an array | Excel Programming |