I’m trying to build a calendar. On my form, I have some unbound fields: [StartDate], [cboMonth], [txtYear]. [cboMonth] is a drop down of the months. The fields [cboMonth] and [txtYear] only serve to let the user select which month he wants to look at. I have a code that sets the field [StartDate] to be the first Sunday on the calendar. It works great. I’m trying to get the dates that are not part of that month to grey out. This is where I’m having problems. The dates are labeled Date1, Date2….through Date42. The list boxes under the date fields are labeled Day1, Day2….through Day42. I used this code:
Private Sub GreyOutDates()
Dim X As Integer
Dim S1 As String, S2 As String
For X = 1 To 42
S1 = "Date" & X
S2 = "Day" & X
If Month(S1) <> Me.cboMonth Then
Forms!frmSchShiftCalendar(S2).BackColor = &HD8D8D8
End If
Next X
EndSub
It goes to the debugger and the “if” statement is wrong. I’m having a hard time getting this done.