hi, i have a combo box on a form that will be used to open reports. the combo box has years in it. i want to check when the form opens if the current year is listed as an option, if not, i want to add it to the top of the list. i can manage that just fine. the problem is that if i comment out the code, the value that was "added" is no longer in the list. in 2006, 2005 will no longer be listed in the combo box. in 2007, 2006 won't be listed. is there a way to make these values persist?
Code:
Private Sub Form_Open(Cancel As Integer)
Dim x As Integer
x = cmbYear.ListCount
If (cmbYear.ItemData(0) = CStr(Year(Now()))) Then
Exit Sub
Else
cmbYear.AddItem Item:=CStr(Year(Now())), Index:=0
End If
End Sub