I am using VBA and wanted to get the Count of the records and retrieve the first and last record of a SQL Query result.
it returns the following, which is correct
qCL
556.54
536.19
528.50
534.95
526.75
535.00
First thing I notice I get the wrong count using rs.Fields.Count. It returns 1. It should return 6. Here is part of the VBA code
Code:
Select Top 6 qCL from Quotes WHERE qTicker ='GOOG';
qCL
556.54
536.19
528.50
534.95
526.75
535.00
First thing I notice I get the wrong count using rs.Fields.Count. It returns 1. It should return 6. Here is part of the VBA code
Code:
Dim result as Variant
Dim cn As New ADODB.Connection
cn.Open ConnectionString
Dim query as String
Query = "Select Top 6 qCL from Quotes WHERE qTicker ='GOOG'; "
Dim rs As New ADODB.RecordSet
rs.Open query, cn, adOpenForwardOnly, adLockReadOnly
totalResults = rs.Fields.Count
FirstPrice = rs.Fields(0)
LastPrice = rs.Fields(5)