frosty2000
Technical User
Hello,
I have created an Access form to track the benefit selections of our employees. Our employee's benefits coverage ends on the last day of the month in which they terminate. (Therefore, if someone terminates on 2/1/05, benefits would end on 2/28/05. Or, if they term on 2/28/05, they would end on 2/28/05).
I have a field TerminationDate that tracks the employee's termination date. I also have a checkbox field EmployeeMedicalCoverage that is checked "Yes" if the member is enrolled in a medical plan. After the user inputs a date into the TerminationDate field, I want the system to automatically input the coverage end date into the EmployeeMedicalCoverageEndDate field, provided that field is already blank and the checkbox is True. (However, if that field already has a date in it or if the checkbox is False, then the system should do nothing).
Is this possible to do? I have done some research on the "Date Serial" function but don't really understand how to apply it to my needs. Below is the code I've started, but it's not doing anything. Thanks for your help.
frosty2000
Private Sub TerminationDate_AfterUpdate()
If [TerminationDate] <> Null And [EmployeeMedicalCoverage] = True And [EmployeeMedicalCoverageEndDate] = Null Then
[EmployeeMedicalCoverageEndDate] = DateSerial(Year([TerminationDate]), Month([TerminationDate] + 1), 0)
End If
End Sub
I have created an Access form to track the benefit selections of our employees. Our employee's benefits coverage ends on the last day of the month in which they terminate. (Therefore, if someone terminates on 2/1/05, benefits would end on 2/28/05. Or, if they term on 2/28/05, they would end on 2/28/05).
I have a field TerminationDate that tracks the employee's termination date. I also have a checkbox field EmployeeMedicalCoverage that is checked "Yes" if the member is enrolled in a medical plan. After the user inputs a date into the TerminationDate field, I want the system to automatically input the coverage end date into the EmployeeMedicalCoverageEndDate field, provided that field is already blank and the checkbox is True. (However, if that field already has a date in it or if the checkbox is False, then the system should do nothing).
Is this possible to do? I have done some research on the "Date Serial" function but don't really understand how to apply it to my needs. Below is the code I've started, but it's not doing anything. Thanks for your help.
frosty2000
Private Sub TerminationDate_AfterUpdate()
If [TerminationDate] <> Null And [EmployeeMedicalCoverage] = True And [EmployeeMedicalCoverageEndDate] = Null Then
[EmployeeMedicalCoverageEndDate] = DateSerial(Year([TerminationDate]), Month([TerminationDate] + 1), 0)
End If
End Sub