Hi everyone,
Hope all are ok.
I need your help with the following code, I know that the query results give me 11 records, but when i run it, i got only one, the first one.
Thanks in advance
Option Compare Database
Option Explicit
Dim FirstDate, SecondDate As String
Private Sub CmbReportDate_Click()
If Year(CDate(Me.Cmbreportdate)) = 2011 ThenQueryActuals
End If
End Sub
Private Sub QueryActuals()
Dim db As Database
Dim rst As Recordset
Dim strQuery As String
Dim Temp As Variant
Dim N As Long
FirstDate = Format(DateAdd("m", -11, CDate(Me.Cmbreportdate)), "mm/dd/yyyy")
SecondDate = Me.Cmbreportdate
strQuery = "SELECT [Cards]!country, Sum(TCcountries![Average Exchange]*[Cards]![Actual OK]/-1000000) AS [Actual OK TC],"
strQuery = strQuery & " Sum(TCcountries![Average Exchange]*[Cards]![Budget OK]/-1000000) AS [Bdgt OK TC]"
strQuery = strQuery & " FROM [Cards] INNER JOIN TCcountries ON [Cards].country = TCcountries.[Exchange Country]"
strQuery = strQuery & " WHERE ((([Cards].Description)=""fraudorex"")"
strQuery = strQuery & " AND (([Cards].DateTC) between #" & FirstDate & "# And #" & SecondDate & "#)"
strQuery = strQuery & " AND (([Cards].concept)= ""ecr"" Or ([Cards].concept)= ""edb""))"
strQuery = strQuery & " GROUP BY [Cards].country;"
Set rst = CurrentDb.OpenRecordset(strQuery, dbOpenDynaset)
Temp = rst.GetRows
With rstIf Not .EOF Then
Do Until .EOF
Debug.Print Temp(1, N), Temp(2, N)
.MoveNext
Loop
End If
End Withrst.Close
Set rst = Nothing
End Sub