473,408 Members | 2,839 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,408 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 a have seen but am getting an error
for "Cancel = True". The error is "Compile error: variable not
defined".

Code:
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.
  7. [BookingsSubform].Form![CourtID] & _
  8. ") AND ([BookingsSubform].[Form]![ScheduleID]=" & Me.
  9. [BookingsSubform].[Form]![ScheduleID] & _
  10. ") AND ([BookingsTimeSubform].[Form]!
  11. [ScheduleEndTime]>=#" & _
  12. Format(Me.[BookingsTimeSubform].[Form]!
  13. [ScheduleStartTime], "Medium Time") & _
  14. "#) AND ([BookingsTimeSubform].[Form]!
  15. [ScheduleStartTime]<=#" & _
  16. Format(Me.[BookingsTimeSubform].[Form]!
  17. [ScheduleEndTime], "Medium Time") & _
  18. "#))"
  19.  
  20. Set rsClone = Me.RecordsetClone
  21. rsClone.MoveFirst
  22. rsClone.FindFirst strWhere
  23.  
  24. If rsClone.NoMatch Then
  25. MsgBox ("test")
  26. Cancel = True
  27. Exit Sub
  28. End If
  29. End If
  30. End Sub
  31.  
Any help would be very nice indeed.
John

Feb 19 '07 #1
2 1798
Hi -

Take a look at Allen Browne's Clashing Events application at
http://allenbrowne.com/tips.html. Think it may well be what you're after.

HTH - Bob

ew****@gmail.com wrote:
>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 a have seen but am getting an error
for "Cancel = True". The error is "Compile error: variable not
defined".

Code:
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.    strWhere = "(([BookingsSubform].Form![CourtID]=" & Me.
  6. [BookingsSubform].Form![CourtID] & _
  7.               ") AND ([BookingsSubform].[Form]![ScheduleID]=" & Me.
  8. [BookingsSubform].[Form]![ScheduleID] & _
  9.               ") AND ([BookingsTimeSubform].[Form]!
  10. [ScheduleEndTime]>=#" & _
  11.               Format(Me.[BookingsTimeSubform].[Form]!
  12. [ScheduleStartTime], "Medium Time") & _
  13.               "#) AND ([BookingsTimeSubform].[Form]!
  14. [ScheduleStartTime]<=#" & _
  15.               Format(Me.[BookingsTimeSubform].[Form]!
  16. [ScheduleEndTime], "Medium Time") & _
  17.               "#))"
  18.    Set rsClone = Me.RecordsetClone
  19.    rsClone.MoveFirst
  20.    rsClone.FindFirst strWhere
  21.    If rsClone.NoMatch Then
  22.        MsgBox ("test")
  23.       Cancel = True
  24.        Exit Sub
  25.    End If
  26. End If
  27. End Sub

Any help would be very nice indeed.
John
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200702/1

Feb 19 '07 #2
Cancel is defined in the beforeUpdate event, not onCurrent.
Try your code there. -tc
I have tried to modify the code a have seen but am getting an error
for "Cancel = True". The error is "Compile error: variable not
defined".
Feb 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Dave Robinson | last post by:
I was wondering if anyone could help me with a problem I'm having. I've been using Dreamweaver to create a hotel booking system for a friend of mine, using MySQL (version 4.0.21) and PHP 5. The...
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...
50
by: johnblack | 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.