Public Function gridClick()
'This just demoes a single function that fires when any of the grid text boxes are clicked
Dim ctl As Access.Control
Dim strMonth As String
Dim intCol As String
Dim intMonth As Integer
Dim intDay As Integer
Dim frm As Access.Form
Dim intYear As Integer
Dim selectedDate As Date
Dim empID As Long
Dim strWhere As String '============Added
Set ctl = Screen.ActiveControl
Set frm = ctl.Parent
strMonth = Replace(Split(ctl.Tag, ";")(0), "txt", "")
intCol = CInt(Split(ctl.Tag, ";")(1))
intYear = CInt(frm.cboYear.Value)
intMonth = getIntMonthFromString(strMonth)
intDay = intCol - getOffset(intYear, intMonth, vbSaturday)
selectedDate = DateSerial(intYear, intMonth, intDay)
empID = Nz(frm.cboEmployee, 0)
'Since you know the date you could now open a form to
'add, edit, or delete a value for that date and that empID
'MsgBox selectedDate & " EmpID" & empID
strWhere = "AbsenceDate = #" & selectedDate & "# AND EmployeeID = " & empID '============Added
If DCount("*", "tbl_YearCalendar", strWhere) Then '============Added
'Date/Emp already exists open frm_CalendarInputBox
DoCmd.OpenForm "frm_CalendarInputBox", , , , , acDialog, Format(selectedDate, "mm/dd/yyyy") & ";" & empID
Else
Const cstrPrompt As String = "Absence record does not exist for this date. Create a new Absence?"
If MsgBox(cstrPrompt, vbQuestion + vbYesNo) = vbYes Then
'Yes I want to create an event
DoCmd.OpenForm "frm_CalendarInputBox", , , , , acDialog, Format(selectedDate, "mm/dd/yyyy") & ";" & empID
'refill the text grid when frm_CalendarInputBox closes
FillTextBoxes Forms("frm_YearCalendar"), empID, intYear
Forms!frm_YearCalendar!cmdTransparentButton.SetFocus '============Added so cur isnt sitting on text box
End If
'Nope lets get outa here
Forms!frm_YearCalendar!cmdTransparentButton.SetFocus '============Added so cur isnt sitting on text box
Exit Function
End If
FillTextBoxes Forms("frm_YearCalendar"), empID, intYear
End Function