G
Guest
I have three nested loops. I get in error on inner while loop:
While Not rscount.EOF
The error states "Wend without While". The code is below.
I'm not sure what I'm doing wrong... Does anyone see anything?
Thanks in Advance!
Elena
StrMonth = 1
While Not StrMonth = 13
strYear = 2002
While Not strYear = 2009
strCount = 0
strTotal = 0
strsql = "Select * from TempTransfer where TransMonth = " & StrMonth & " and
TransYear = " & strYear
Set rscount = CurrentDb.OpenRecordset(strsql)
rscount.MoveFirst
While Not rscount.EOF
If rscount.RecordCount > 0 Then
strDiff = rscount!Difference
strTotal = strTotal + strDiff
strCount = strCount + 1
rscount.MoveNext
Wend
average = strDiff / strTotal
strsql = "Insert into TempAverage values (" & StrMonth & ", " & strYear & ",
" & average & ")"
CurrentDb.Execute (strsql)
End If
strYear = strYear + 1
Wend
StrMonth = StrMonth + 1
Wend
While Not rscount.EOF
The error states "Wend without While". The code is below.
I'm not sure what I'm doing wrong... Does anyone see anything?
Thanks in Advance!
Elena
StrMonth = 1
While Not StrMonth = 13
strYear = 2002
While Not strYear = 2009
strCount = 0
strTotal = 0
strsql = "Select * from TempTransfer where TransMonth = " & StrMonth & " and
TransYear = " & strYear
Set rscount = CurrentDb.OpenRecordset(strsql)
rscount.MoveFirst
While Not rscount.EOF
If rscount.RecordCount > 0 Then
strDiff = rscount!Difference
strTotal = strTotal + strDiff
strCount = strCount + 1
rscount.MoveNext
Wend
average = strDiff / strTotal
strsql = "Insert into TempAverage values (" & StrMonth & ", " & strYear & ",
" & average & ")"
CurrentDb.Execute (strsql)
End If
strYear = strYear + 1
Wend
StrMonth = StrMonth + 1
Wend