Click to go home
This is the event scheduler form

Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdUpdate_Click()
' Verify date
If dtpDate.Value = Date And Format(dtpTime.Value, "hh:mm") > Format(Time(), "hh:mm") Then
With deContacts.rsEventScheduler
.AddNew
!ContactID = txtContactId.Text
!ScheduledDate = dtpDate.Value
!ScheduledTime = Format(dtpTime.Value, "hh:mm")
!Comments = txtComments.Text
.UpdateBatch
End With
MsgBox "The database has been updated.", , "Update"
Exit Sub
ElseIf dtpDate.Value > Date Then
With deContacts.rsEventScheduler
.AddNew
!ContactID = txtContactId.Text
!ScheduledDate = dtpDate.Value
!ScheduledTime = Format(dtpTime.Value, "hh:mm")
!Comments = txtComments.Text
.UpdateBatch
End With
MsgBox "The database has been updated.", , "Update"
Exit Sub
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 Sub
Private Sub Form_Load()
deContacts.Names
deContacts.EventScheduler
' Unbound commands
txtContactId.Text = ""
txtComments.Text = " "
' Check to see if the recordset is empty
If deContacts.rsNames.BOF And deContacts.rsNames.EOF Then
MsgBox "There are no contacts in the database.", , "Contacts"
Exit Sub
End If
' Move to the beginning of the recordset
If deContacts.rsNames.BOF = False Then
deContacts.rsNames.MoveFirst
End If
' Show the contact names in the list box
With deContacts.rsNames
While Not .EOF
' Add a name to the list
lstNames.AddItem .Fields("LastName").Value & ", " & _
.Fields("FirstName").Value
lstNames.ItemData(lstNames.NewIndex) = .Fields("ContactID")
.MoveNext
Wend
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
'close the unbound record set
deContacts.rsNames.Close
deContacts.rsEventScheduler.Close
End Sub
Private Sub lstNames_Click()
cmdUpdate.Enabled = True
'Display the Contact Id on the event scheduler form
txtContactId.Text = lstNames.ItemData(lstNames.ListIndex)
End Sub
Private Sub lstNames_GotFocus()
If deContacts.rsNames.BOF And deContacts.rsNames.EOF Then
Unload Me
End If
End Sub
Private Sub txtContactId_Click()
' Force the user to highlight a contact on the list
' Textbox locked
MsgBox "Please select a contact from the list", vbExclamation, _
"Contact ID"
End Sub
Next Page - Completed Events
Jump to:
Main |
Contact Maintenance |
Contact Info |
Event Reminder
Go to top