Stop duplicates (1 Viewer)

tw15ns

New member
Local time
Today, 08:25
Joined
Jun 21, 2017
Messages
1
Hi first time here and just getting back into using Access. I am trying to set up a parents evening booking system. I have 3 tables: Staff, Student and Appointment. The Appointment table has StudentID, StaffId and Time fields. I can stop a student trying to book the same time slot with two teachers by making the primary key Time and StudentID but this will not stop a teacher booking different students into the same slot (and believe me some will try). I don't want to create blank slots for all the teachers which would stop this double booking so does anyone have any idea how I can prevent double bookings of whatever kind.

Cheers
 

isladogs

MVP / VIP
Local time
Today, 16:25
Joined
Jan 14, 2017
Messages
18,211
Hi

For my parents appointments system, I use a composite PK field in the appointments table comprising:
YearGroup + Staff ID + Parents Evening Date (as long) + Time (hhnn)
e.g. 10ANO37348-1640

Screenshots:





As you can see, it also records the name of the parents attending, phone number etc. The form also allows staff to check off which parents attended or failed to attend in case a follow up is needed
 

Attachments

  • PApptTable.PNG
    PApptTable.PNG
    42.6 KB · Views: 355
  • PAppts.PNG
    PAppts.PNG
    70.6 KB · Views: 367

CJ_London

Super Moderator
Staff member
Local time
Today, 16:25
Joined
Feb 19, 2013
Messages
16,605
assuming your time fields are datetime, and not just time then something like this will tell you if either student or teacher are already booked for a specific time

Code:
if dcount("*","tblAppointments","(StudentID=" & me.studentID & " OR teacherID=" & me.teacherID & ") AND AppointmentTime=#" & format(me.appointmenttime,"mm/dd/yyyy hh:mm") & "#")=0 then
    msgbox "appointment is OK"
else
    msgbox "appointment conflicts"
end if
Note that Time is a reserved word and should not be used as a field name.
 

isladogs

MVP / VIP
Local time
Today, 16:25
Joined
Jan 14, 2017
Messages
18,211
Note that Time is a reserved word and should not be used as a field name.

I should have said that Date & Time are field captions not the actual field names which are ApptDate / ApptTime
 

Users who are viewing this thread

Top Bottom