D
Debbie Hatten
HELP!!! I am getting a run time error 3021 - no current
record when I try to export query results to an Excel
file. I do NOT get the RTE when I view the query in
Access. The query contains a function that I designed
based on KB article #210138 to compute a moving average.
It seems to be hanging up on the rst.movelast line
Here's my code:
Function GMovAvg(Property, startDate, period As Integer)
Dim rst As DAO.Recordset
Dim sql As String
Dim ma As Currency
Dim n
sql = "Select * from calculations "
sql = sql & "where property = '" & Property & "'"
sql = sql & " and date < #" & startDate & "#"
sql = sql & " order by date"
Set rst = CurrentDb.OpenRecordset(sql)
rst.MoveLast
For n = 0 To period - 1
If rst.BOF Then
GMovAvg = 0
Exit Function
Else
ma = ma + rst.Fields("gross sales gas")
End If
rst.MovePrevious
Next n
rst.Close
GMovAvg = ma / period
record when I try to export query results to an Excel
file. I do NOT get the RTE when I view the query in
Access. The query contains a function that I designed
based on KB article #210138 to compute a moving average.
It seems to be hanging up on the rst.movelast line
Here's my code:
Function GMovAvg(Property, startDate, period As Integer)
Dim rst As DAO.Recordset
Dim sql As String
Dim ma As Currency
Dim n
sql = "Select * from calculations "
sql = sql & "where property = '" & Property & "'"
sql = sql & " and date < #" & startDate & "#"
sql = sql & " order by date"
Set rst = CurrentDb.OpenRecordset(sql)
rst.MoveLast
For n = 0 To period - 1
If rst.BOF Then
GMovAvg = 0
Exit Function
Else
ma = ma + rst.Fields("gross sales gas")
End If
rst.MovePrevious
Next n
rst.Close
GMovAvg = ma / period