Hello,
I have a database where I insert client appointments through a form. To avoid enterring duplicated appointments, a message pops up when the date, time and counsellor name already exist in the Appointments table. In the AfterUpdate event of the Counsellor command I added this event procedure:
Private Sub txtCounsellorID_AfterUpdate()
If Not IsNull(DLookup("[AppointmentID]", "tblAppointments", "[TimeID] = " & Me.txtTimeID & " AND [AppointmentDate]= #" & Me.AppointmentDate & "# AND [CounsellorID]= " & Me.txtCounsellorID & " ")) Then
MsgBox "Double Booking, change time, date or counsellor"
Me.Undo
End If
End Sub
This works perfectly. However I was trying to add an appointment on 8th September 2010 8/09/10 and it kept on saying there was a duplicate when this was not the case. I then figured out by doing a few tests that I had an appointment on the 9th of August 2010, 9/08/10, at the same time with the same counsellor. I tested reversing other dates and this happened every time. It seems like Access is taking 8/09/10 to be the same as 9/08/10. The field AppointmentDate format is Date/Time Short Date and the first number should be the day and the second the month.
Has this happened to anybody else before? Is there a way I can work around this? Please help! Thanks!