Private Sub Selected_Click()
If Selected Then
AddSelection
Else
RemoveSelection
End If
End Sub
Public Sub AddSelection()
Dim strSql As String
Dim DailyDate As Date
Dim SelectionID As Long
Dim PersonID As Long
If IsNull(Me.Parent.CmboPerson) Or IsNull(Me.Parent.cmboDate) Then
MsgBox "Ensure a date and person are selected", vbInformation, "Ensure Data"
Else
PersonID = Me.Parent.CmboPerson
SelectionID = Me.TaskSelection_ID
DailyDate = Me.Parent.cmboDate
strSql = "Insert into tblPersonDailyTasks (Person_ID_FK, TaskSelection_ID_FK, TaskDate) VALUES (" & PersonID & ", " & SelectionID & ", #" & Format(DailyDate, "MM/DD/YYYY") & "#)"
Debug.Print strSql
CurrentDb.Execute strSql
End If
End Sub
Public Sub RemoveSelection()
Dim strSql As String
Dim DailyDate As Date
Dim SelectionID As Long
Dim PersonID As Long
If IsNull(Me.Parent.CmboPerson) Or IsNull(Me.Parent.cmboDate) Then
MsgBox "Ensure a date and person are selected", vbInformation, "Ensure Data"
Else
PersonID = Me.Parent.CmboPerson
SelectionID = Me.TaskSelection_ID
DailyDate = Me.Parent.cmboDate
strSql = "Delete * from tblPersonDailyTasks WHERE Person_ID_FK = " & PersonID & " AND TaskSelection_ID_FK = " & SelectionID & " AND TaskDate = #" & Format(DailyDate, "MM/DD/YYYY") & "#"
Debug.Print strSql
CurrentDb.Execute strSql
End If
End Sub