Hi,
I am trying to get this recordset to work. My SQL statement is correct, I checked it in the query builder grid and it worked. Is there something that I need to turn on or declare, that is not done, to get the recordset to work? Or is there something to turn on for the dbOpenSnapshot? I have beaten my head against the wall on this one!!
Here is my code:
I appreciate any comments/help!
Thank You,
nicmar
I am trying to get this recordset to work. My SQL statement is correct, I checked it in the query builder grid and it worked. Is there something that I need to turn on or declare, that is not done, to get the recordset to work? Or is there something to turn on for the dbOpenSnapshot? I have beaten my head against the wall on this one!!
Here is my code:
Code:
Set gdbAll = CurrentDb
Dim strClass As String
Dim strTestNum As String
Dim rsStatistics As Recordset
Dim rsFailures As Recordset
strTestNum = [Forms]![TestScore]![cboTestName]
strClass = [Forms]![TestScore]![cboClass]
Debug.Print gstrSQL
gstrSQL = "SELECT [SDataQ].[Class], Count _
([SDataQ].strTestNum]) AS "
gstrSQL = gstrSQL & "NumberOfStudents, Avg _
([SDataQ].strTestNum]) AS txtAverage, "
gstrSQL = gstrSQL & "Min([SDataQ].[strTestNum]) AS _
MinOfScore, "
gstrSQL = gstrSQL & "Max([SDataQ].[strTestNum]) AS _
MaxOfScore "
gstrSQL = gstrSQL & "FROM [SDataQ] "
gstrSQL = gstrSQL & "WHERE SDataQ.Class= " & [Forms]! _
[TestScore]![cboClass] & ";"
Set rsStatistics = gdbAll.OpenRecordset(gstrSQL, _
dbOpenSnapshot)
If rsStatistics.RecordCount <> 0 Then
txtMaxScore = rsStatistics!MaxOfScore
txtMinScore = rsStatistics![MinOfScore]
txtAverage = rsStatistics![AvgOfScore]
End If
rsStatistics.Close
I appreciate any comments/help!
Thank You,
nicmar