HELP:Adding multiple queries to one recordset

tatendatiffany

Board Regular
Joined
Mar 27, 2011
Messages
103
Is there a way of adding multiple sql queries in the same record or do i have to do separate recordsets each time i have a new query: the area in bold is my attempt to add another query am i on the right path or i am missing some important parameters
HTML:
Dim rs As ADODB.RecordsetDim cn As ADODB.ConnectionDim strSQL1 As StringstrSQL1 = "SELECT COUNT (INUNACPT) FROM AIS3.QM4.KTPT80T WHERE CDPRODCO=RETAIL_MAP"str2SQL2="SELECT COUNT (INACCEPT) FROM AIS3.KTPT81T WHERE CDRPODCO=RETAIL_MAP"Set rs = New ADODB.RecordsetSet cn = New ADODB.Connectioncn.Open CONNECTION_STRING '//You must provide a connection string herers.Open strSQL1, cnrs.Open strSQL2,cnrs.CopyFromRecordset Index.Range("AC2")rs.CopyRecordset Index.Range ("AC3")rs.Closecn.Close
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Code:
Dim rs As ADODB.RecordsetDim cn As ADODB.ConnectionDim strSQL1 As StringstrSQL1 = "SELECT COUNT (INUNACPT) FROM AIS3.QM4.KTPT80T WHERE CDPRODCO=RETAIL_MAP"[B]str2SQL2="SELECT COUNT (INACCEPT) FROM AIS3.KTPT81T WHERE CDRPODCO=RETAIL_MAP"[/B]Set rs = New ADODB.RecordsetSet cn = New ADODB.Connectioncn.Open CONNECTION_STRING '//You must provide a connection string herers.Open strSQL1, cn[B]rs.Open strSQL2,cn[/B]rs.CopyFromRecordset Index.Range("AC2")[B]rs.CopyRecordset Index.Range ("AC3")[/B]rs.Closecn.Close</PRE>
 
Upvote 0
Dim rs As ADODB.RecordsetDim cn As ADODB.ConnectionDim strSQL1 As StringstrSQL1 = "SELECT COUNT (INUNACPT) FROM AIS3.QM4.KTPT80T WHERE CDPRODCO=RETAIL_MAP"str2SQL2="SELECT COUNT (INACCEPT) FROM AIS3.KTPT81T WHERE CDRPODCO=RETAIL_MAP"Set rs = New ADODB.RecordsetSet cn = New ADODB.Connectioncn.Open CONNECTION_STRING '//You must provide a connection string herers.Open strSQL1, cnrs.Open strSQL2,cnrs.CopyFromRecordset Index.Range("AC2")rs.CopyRecordset Index.Range ("AC3")rs.Closecn.Close
</PRE>
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top