473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Double Booking Problem

I am creating a tennis court booking system. I am trying to create a macro that will not allow the same court to be booked on the same date at the same time.

I have the following tables and fields

tblMembers
MemberID
FirstName
LastName
etc

tblCourts
CourtID
CourtName

tblSchedule
ScheduleID
ScheduleDate
CourtID

tblSheduleDetails
SheduleDetailsID
SheduleID
MemberID
SheduleStartTime
SheduleEndTime

I have tried to modify the code form a similar post but am getting an error for "Cancel = True"

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me.NewRecord = True Then
  3.     Dim strWhere As String, strMessage As String
  4.     Dim rsClone As Recordset
  5.  
  6.     strWhere = "(([BookingsSubform].Form![CourtID]=" & Me.[BookingsSubform].Form![CourtID] & _
  7.                ") AND ([BookingsSubform].[Form]![ScheduleID]=" & Me.[BookingsSubform].[Form]![ScheduleID] & _
  8.                ") AND ([BookingsTimeSubform].[Form]![ScheduleEndTime]>=#" & _
  9.                Format(Me.[BookingsTimeSubform].[Form]![ScheduleStartTime], "Medium Time") & _
  10.                "#) AND ([BookingsTimeSubform].[Form]![ScheduleStartTime]<=#" & _
  11.                Format(Me.[BookingsTimeSubform].[Form]![ScheduleEndTime], "Medium Time") & _
  12.                "#))"
  13.  
  14.     Set rsClone = Me.RecordsetClone
  15.     rsClone.MoveFirst
  16.     rsClone.FindFirst strWhere
  17.  
  18.     If rsClone.NoMatch Then
  19.         MsgBox ("test")
  20.        Cancel = True
  21.         Exit Sub
  22.     End If
  23. End If
  24. End Sub
Any help would be very nice indeed.
John
Feb 19 '07
50 5480
NeoPa
32,556 Expert Mod 16PB
New post moved to it's own thread (Access 2007 Template Appointment Manager)

PS. Never mind. Not only a hijack but also a double-post. Presumably a new user of forums. Anyway, the remaining thread is found at tennis court booking database.
Jan 3 '10 #51

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

Similar topics

4
by: Grant | last post by:
Hi I have a database which logs the usage of rooms. Some booking are entered well in advance, and some have stays of more than six months. I would like to ensure that rooms which have been...
2
by: Andy | last post by:
Hi folks I teach. At school, four IT rooms are booked using a paper based outline timetable. Completing it is easy but basic and impossible to ensure completion of all fields (name, year...
4
by: markymark34 | last post by:
Im messing around trying to learn Access and have hit a problem. I have a table called tblbookings and i want to seach though it when trying to make a new booking to make sure the room isnt alrady...
2
by: ewan89 | last post by:
I am creating a tennis court booking system. I am trying to create a macro that will not allow the same court to be booked on the same date at the same time. I have the following tables and...
25
by: NDayave | last post by:
How do, I have a access 2000 booking database with Personal Details, Outing Details and the Bookings in three tables: tblBookings -- -Autonumber, -Number, -Number, -Currency, -Yes/No, -Yes/No ...
6
by: iazahoor | last post by:
I use Access 2000 and I'm trying to figure out what VBA code to use to prevent double bookings. Any help on this matter will be greatly appreciated. Regards Immy
3
by: anotherjoe | last post by:
Question 1: I have reservation database in access 2007 I have a cabin information table with: cabinid (primarykey) cabinname(text) cabinlocation(text) I have a customer table with:...
3
by: Keyboyx | last post by:
I am creating a Dentist Booking form, for my A level project. I have the following Tables: Appointments Appointment ID Dentist ID Patient ID Appointment Date Appointment Time
3
by: Wayne | last post by:
I'm building a bookings database for trucks that among other things captures the TruckName, LoadDate, LoadTime, UnloadDate and UnloadTime. Is there a simple way to prevent double bookings for any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.