I debug and it takes me to:
Set GetTodaysTextBox = Forms("Frm_YearCalendar").Controls(txtBxName)
the Debug.Print txtBxName is "txtDec33" and Debug.Print offset is "5" it is picking the correct month and day everywhere. Thoughts?
CODE --> VBA
Public Sub TestHilite() GetTodaysTextBox.BorderColor = vbYellow End Sub Public Function GetTodaysTextBox() As Access.TextBox Dim CurrentDay As Date Dim strMonth As String Dim offset As Integer Dim txtBxName As String CurrentDay = Date strMonth = Format(CurrentDay, "mmm") 'Debug.Print strMonth offset = getOffset(Year(CurrentDay), Month(CurrentDay), vbSaturday) Debug.Print offset txtBxName = "txt" & strMonth & offset + Day(CurrentDay) Debug.Print txtBxName Set GetTodaysTextBox = Forms("Frm_YearCalendar").Controls(txtBxName) End Function
UPDATE: I changed vbSaturday to vbSunday because my calendar starts on Sun - Sat and now the txtBxName is "txtDec32" which if you count the text boxes its todays day so that's correct. But I still get the same error just now with "txtDec32".