I have the code shown below on the open event on a form in Access 2003. When opening the form, I get a type mismatch error on the line that says "If fyear > Year(Now()) Then". I copied this code from another form where it works fine. What could be the problem?
Dim rs As DAO.Recordset
Dim fyear As Integer
Dim i As Integer
DoCmd.OpenQuery "Clear FiscalYears"
Set rs = CurrentDb.OpenRecordset("FiscalYears")
fyear = 2000
For i = 1 To 100
fyear = fyear + 1
If fyear > Year(Now()) Then
rs![fiscalyear] = Format(fyear, "0000")