Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subscript out of range error

Status
Not open for further replies.

mkal

Programmer
Jun 24, 2003
223
US
I have a DTS package that uses a lookup query that returns information from 4 different fields. In an ActiveXscript I am trying to retrieve that information into an array. But when I run it I get a "Type mismatch:'varArray'" error. BOL has this to say about it.

Sometimes you want to retrieve multiple values with a single lookup (for example, when you have a customer account number and need a name and address).

Data Transformation Services (DTS) handles multiple columns in query results by returning an array of variants. Each entry in the array holds one result value. The index of the first value is 0.

In this example, you need to retrieve a city and a region, given the postal code. The GetCityAndRegion query selects both required columns:

SELECT City, Region FROM MailCodes WHERE PostalCode = ?

The returned values are accessed through the following ActiveX script code:

dim varArray
varArray = DTSLookups("GetCityAndRegion").Execute(DTSSource("PostalCode"))
DTSDestination("City") = varArray(0)
DTSDestination("Region") = varArray(1)

My Lookup Query:

SELECT col1, col2, col3, col4 FROM table_name WHERE col1 = ? and col2 = ? and col3 = col4 = ?

My ActiveX script:

dim varArray, arrayValue1, arrayValue2, arrayValue3, arrayValue4
varArray = DTSLookups("get_keyValues").Execute(DTSSource("value1"), DTSSource("value2"), DTSSource("value3"), DTSSource("value4"))
arrayValue1 = varArray(0)
arrayValue2 = varArray(1)
arrayValue3 = varArray(2)
arrayValue4 = varArray(3)

Error Msg: The number of failing rows exceeds the maximum specified.
Error code: 0
Error Source= Microsoft VBScript runtime error
Error Description: Type mismatch: 'varArray'

Error on line 3 (which is arrayValue1 = varArray(0))

Any help would be much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top