Click to go home
This is the event reminder form

Option Explicit
Private Sub cmdComplete_Click()
' Complete the late event
lblScheduledDate.Caption = "Completed Date:"
lblScheduledTime.Caption = "Completed Time:"
dtpDate.Value = Date
dtpTime.Value = Time
cmdUpdate.Enabled = True
cmdReschedule.Enabled = False
cmdUpdate_Click
End Sub
Private Sub cmdReschedule_Click()
' Reschedule the late event
dtpDate.SetFocus
cmdUpdate.Enabled = True
cmdComplete.Enabled = False
End Sub
Private Sub cmdUpdate_Click()
' If the user chooses to reschedule the event
If cmdComplete.Enabled = False Then
' Check that the scheduled date/time are in the future
If dtpDate.Value = Date And _
Format(dtpTime.Value, "hh:mm") > Format(Time(), "hh:mm") Then
' Save new date and time in Scheduled events table
With deContacts.rsTimer
!ScheduledDate = dtpDate.Value
!ScheduledTime = Format(dtpTime.Value, "hh:mm")
.UpdateBatch
End With
MsgBox "The database has been updated.", , "Update"
Unload Me
ElseIf dtpDate.Value > Date Then
' Save new date and time in Scheduled events table
With deContacts.rsTimer
!ScheduledDate = dtpDate.Value
!ScheduledTime = Format(dtpTime.Value, "hh:mm")
.UpdateBatch
End With
MsgBox "The database has been updated.", , "Update"
Unload Me
ElseIf dtpDate.Value < Date Then
MsgBox "Your scheduled date must be in the future.", vbExclamation _
, "Date"
dtpDate.SetFocus
Exit Sub
Else
MsgBox "Your scheduled time must be in the future.", vbExclamation _
, "Time"
dtpTime.SetFocus
Exit Sub
End If
End If
' If the user chooses to complete the event
If cmdReschedule.Enabled = False Then
' Add a new record to the completed events table
deContacts.rsCompletedReminder.AddNew
With deContacts.rsCompletedReminder.Fields
!ContactID = deContacts.rsTimer!ContactID
!ScheduledDate = deContacts.rsTimer!ScheduledDate
!ScheduledTime = deContacts.rsTimer!ScheduledTime
!CompletedDate = dtpDate.Value
!CompletedTime = Format(dtpTime.Value, "hh:mm")
End With
deContacts.rsCompletedReminder.UpdateBatch
' Delete the record from the scheduled events recordset
With deContacts.rsTimer
.Delete
.UpdateBatch
.MoveNext
If .RecordCount = 0 Then
MsgBox "The database has been updated.", , "Update"
Unload Me
Exit Sub
ElseIf .EOF Then .MoveLast
End If
End With
MsgBox "The database has been updated.", , "Update"
Unload Me
End If
End Sub
Private Sub Form_Load()
deContacts.NamesReminder
deContacts.CompletedReminder
Dim varBookmark As Variant
Beep
' Fill text boxes
dtpDate.Value = deContacts.rsTimer!ScheduledDate
dtpTime.Value = deContacts.rsTimer!ScheduledTime
' Move to the beginning of the recordset
If deContacts.rsNamesReminder.BOF = False Then
deContacts.rsNamesReminder.MoveFirst
End If
' Search to find names associated with Contact ID
With deContacts.rsNamesReminder
varBookmark = .Bookmark
.Find "ContactId = '" & deContacts.rsTimer!ContactID & "'", 0, _
adSearchForward, adBookmarkFirst
If .EOF Or .BOF Then
.Bookmark = varBookmark
MsgBox "Record Not Found.", vbExclamation, "Record"
End If
txtName.Text = !FirstName & " " & !LastName
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Close the recordsets
deContacts.rsCompletedReminder.Close
deContacts.rsNamesReminder.Close
End Sub
Go Back Home
Jump to:
Main |
Contact Maintenance |
Contact Info |
Event Scheduler |
Completed Events
Go to top