I need to know how to compare the date of an appointment with the time the appointment is scheduled for so that if the time is = to a time on the same dat it will not let you enter it.
Printable View
I need to know how to compare the date of an appointment with the time the appointment is scheduled for so that if the time is = to a time on the same dat it will not let you enter it.
If Format(Date1, "mm/dd/yyyy") = Format(Date2, "mm/dd/yyyy") Then
If Format(Time1, "hh:mm:ss") = Format(Time2, "hh:mm:ss") Then
'Both appointments are at the same time
End If
End If
Does that help??
Why not simply:
If Date1 = Date2 Then...? ;-)
Thanks your suggestion worked out well for me...
Quote:
Originally Posted by rtwitty
ok this is how it looks in the record: (This is Access 2000 by the way)
(appointmentdate set by calendar control)
appointmentdate Appointmenttime
record 1 2/8/2005 7:30 AM wrong
record 2 2/8/2005 7:30 AM
these are the two record fields. I can't have an appointment scheduled at the same time, on the same date. If the date changes, then the time can remain, but if the date is the same for both records then the time must change.
(appointmentdate set by calendar control)
appointmentdate Appointmenttime
record 1 2/7/2005 7:30 AM right
record 2 2/8/2005 7:30 AM
(appointmentdate set by calendar control)
appointmentdate Appointmenttime
record 1 2/8/2005 7:30 AM right
record 2 2/8/2005 7:45 AM
is there a macro or vb code that can check this when they type it in?
I recommend storing the date and time in a single field. Then add a unique index on the date/time field; Access will throw an error if you try to schedule two appointments at the same time.