Hi Everyone,
I have a pass-through query that pulls data for a certain cluster number from the DB2 IBM database using an OBDC. I can only run the query for two group numbers at a time since there is a large amount of data that is returned. I also have a make table query and append table query. What I would like to be able to do is connect to the OBDC DB2 server, run the pass-through query for the first cluster number, create a table with the make table query, run the pass through query again with second group number, and append this to the table from the make table query and so forth until I have gone through the list of cluster numbers.
I have a list of cluster numbers: (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20….etc.) which I need to run the query on and append to the table.
My pass-through query looks something like this:
SELECT DISTINCT VEND_ID, STATE, SALES, COST
FROM SALES_TABLE
WHERE CLUSTER_NUMBER IN (1,2)
AND (STATE= ‘CALIFORNIA’ AND VEND_ID IN(‘11’)
OR (STATE= ‘OREGON’ AND VEND_ID IN(‘12’)
OR (STATE= ‘WASHINGTON’ AND VEND_ID IN(‘13’)
OR (STATE= ‘NEVADA’ AND VEND_ID IN(‘14’)
OR (STATE= ‘ARIZONA’ AND VEND_ID IN(‘15’)
OR (STATE= ‘IDAHO’ AND VEND_ID IN(‘16’)
OR (STATE= ‘UTAH’ AND VEND_ID IN(‘17’)
OR (STATE= ‘TEXAS’ AND VEND_ID IN(‘18’))
My make table query code looks like this:
SELECT passthrough_query.*INTO Sales_Data
FROM passthrough_query
My append table query looks like this:
INSERT INTO Sales_Data (VEND_ID, STATE, SALES, COST)
SELECT passthrough_query.VEND_ID, passthrough_query.STATE, passthrough_query.SALES, passthrough_query.COST
FROM passthrough_query
If anyone has some ideas of how to do this in VBA, or offer some help to get this automated, I would really appreciate it. Thanks!
I have a pass-through query that pulls data for a certain cluster number from the DB2 IBM database using an OBDC. I can only run the query for two group numbers at a time since there is a large amount of data that is returned. I also have a make table query and append table query. What I would like to be able to do is connect to the OBDC DB2 server, run the pass-through query for the first cluster number, create a table with the make table query, run the pass through query again with second group number, and append this to the table from the make table query and so forth until I have gone through the list of cluster numbers.
I have a list of cluster numbers: (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20….etc.) which I need to run the query on and append to the table.
My pass-through query looks something like this:
SELECT DISTINCT VEND_ID, STATE, SALES, COST
FROM SALES_TABLE
WHERE CLUSTER_NUMBER IN (1,2)
AND (STATE= ‘CALIFORNIA’ AND VEND_ID IN(‘11’)
OR (STATE= ‘OREGON’ AND VEND_ID IN(‘12’)
OR (STATE= ‘WASHINGTON’ AND VEND_ID IN(‘13’)
OR (STATE= ‘NEVADA’ AND VEND_ID IN(‘14’)
OR (STATE= ‘ARIZONA’ AND VEND_ID IN(‘15’)
OR (STATE= ‘IDAHO’ AND VEND_ID IN(‘16’)
OR (STATE= ‘UTAH’ AND VEND_ID IN(‘17’)
OR (STATE= ‘TEXAS’ AND VEND_ID IN(‘18’))
My make table query code looks like this:
SELECT passthrough_query.*INTO Sales_Data
FROM passthrough_query
My append table query looks like this:
INSERT INTO Sales_Data (VEND_ID, STATE, SALES, COST)
SELECT passthrough_query.VEND_ID, passthrough_query.STATE, passthrough_query.SALES, passthrough_query.COST
FROM passthrough_query
If anyone has some ideas of how to do this in VBA, or offer some help to get this automated, I would really appreciate it. Thanks!