By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,204 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,204 IT Pros & Developers. It's quick & easy.

Scheduling Db - Prevent Double Booking

P: 2
I'm a self taught beginner and, with a lot of luck, I've managed to build a db to schedule classes, rooms, and students. But I'm stuck on ensuring students aren't double booked. I assigned a code to all my available time slots, so I can't double book the room, and I have a sub form on my Classes form so that I can see the Instructors schedule. I also have it that a student can't be scheduled for the same class twice. But my mushy brain can't figure out how to get an error message if the student is already scheduled for a session at 8 on Monday. I have to go to the form with the student's schedule. Help - I'm melting!
Feb 24 '07 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,366
What about:
Expand|Select|Wrap|Line Numbers
  1. If DCount("*", "[Table Name]", "[Day Field Name] = " & Me.[Day Control Name] & " [Time Field Name] = " & Me.[Time Control Name]) > 0 Then
  2.   MsgBox "Double Booked"
  3. End If
Feb 24 '07 #2

P: 2
Are these real english words or did you just make them up!

I can vaguely follow the code, I'm just not sure where to "put" it. I use wizrds and such and I've been lucky on joins and realtionships, and I do understand the basics - but que?

Thanks for the quick response though:)

What about:
Expand|Select|Wrap|Line Numbers
  1. If DCount("*", "[Table Name]", "[Day Field Name] = " & Me.[Day Control Name] & " [Time Field Name] = " & Me.[Time Control Name]) > 0 Then
  2.   MsgBox "Double Booked"
  3. End If
Feb 24 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
easiest way to do it is to add a command button to the form and put this code in it.

Mary
Feb 24 '07 #4

Rabbit
Expert Mod 10K+
P: 12,366
You can make a command button called Save, and while it doesn't actually save the record (as that's done automatically if the form is linked to the table) it can run the code. You would probably also want to add Me.Undo after the MsgBox.

Basically if DCount("*", "[Table Name]", "Search Criteria") is larger than 0 then it's double booked. It counts how many records there are where Day and Time are equal to the new record they're creating.
Feb 24 '07 #5

NeoPa
Expert Mod 15k+
P: 31,494
Can you post the MetaData for your tables that are involved in this.
The SQL code used will depend on how you store your dates & times.
A re-usable example of MetaData is included for your use.
Expand|Select|Wrap|Line Numbers
  1. Table Name=tblStudent
  2. Field; Type; IndexInfo
  3. StudentID; Autonumber; PK
  4. Family; String; FK
  5. Name; String
  6. University; String; FK
  7. Mark; Numeric
  8. LastAttendance; Date/Time
Feb 26 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.