Get the Count of Records From a Query

MNpoker

Board Regular
Joined
Dec 15, 2003
Messages
154
How can I get the number of records from the following?

Code:
       VtSQL = ""
        VtSQL = VtSQL & "SELECT QRY_SecondaryDescriptions.Peril_Number, QRY_SecondaryDescriptions.Secondary_Number, QRY_SecondaryDescriptions.Secondary_Value, QRY_SecondaryDescriptions.Secondary_Field, QRY_SecondaryDescriptions.Secondary_Name, QRY_SecondaryDescriptions.Secondary_Value_Name, TempSecondaryQry.CountOfLocID, TempSecondaryQry.SumOfTIVValue " & _
            "FROM TempSecondaryQry INNER JOIN QRY_SecondaryDescriptions ON (TempSecondaryQry." & SecondaryCode & " = QRY_SecondaryDescriptions.Secondary_Value) AND (TempSecondaryQry.Secondary_Number = QRY_SecondaryDescriptions.Secondary_Number) " & _
            "Order By Qry_SecondaryDescriptions.Secondary_Value;"
                  
        Set rst = New ADODB.Recordset
        rst.Open VtSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic

I thought it would be rst.RecordCount but that keeps kicking out a value of -1.

Thanks in advance.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,214,429
Messages
6,119,435
Members
448,898
Latest member
dukenia71

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