473,396 Members | 1,766 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,396 software developers and data experts.

Hotel booking (double bookings)

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 booked.

In tblbookings i have a room_number, booking_start_date and booking_end_date

Ive tried all sorts of code but it either brings up an error or doesnt do anything at all. Hoping someone can help.

Ive got as far as bringing up a message box if it finds the same room already in the booking table (which obviously isnt very useful but its as far as i can get!)
Im using the following code:

Can someone have a look and tell me what i should be doing. Cheers

If Me.NewRecord = True Then
Dim strWhere As String, strmessage As String

strWhere = "Room_Number = " & Me!Room_Number

Me.RecordsetClone.MoveFirst
Me.RecordsetClone.FindFirst strWhere

Do Until Me.RecordsetClone.nomatch
If Me.RecordsetClone!Room_Numnber = Me!Room_Number Then
MsgBox ("test")
Cancel = True
Exit Sub
End If
Me.RecordsetClone.FindNext strWhere
Loop
End If
Nov 28 '06 #1
4 2718
NeoPa
32,556 Expert Mod 16PB
Try this :-
Expand|Select|Wrap|Line Numbers
  1. If Me.NewRecord = True Then
  2.     Dim strWhere As String, strMessage As String
  3.     Dim rsClone as RecordSet
  4.  
  5.     strWhere = "((Room_Number=" & Me.Room_Number & _
  6.                ") AND (Booking_End_Date>=#" & _
  7.                Format(Me.Booking_Start_Date,"m/d/yyyy") & _
  8.                "#) AND (Booking_Start_Date<=#" & _
  9.                Format(Me.Booking_End_Date,"m/d/yyyy") & _
  10.                "#))"
  11.  
  12.     set rsClone = Me.RecordsetClone
  13.     rsClone.MoveFirst
  14.     rsClone.FindFirst strWhere
  15.  
  16.     If rsClone.NoMatch then
  17.         MsgBox ("test")
  18.         Cancel = True
  19.         Exit Sub
  20.     End If
  21. End If
Nov 28 '06 #2
excellent cheers.

only probelm is this wont catch bookings made at different dates eg

room 101 - booked from 1st dec - 5th dec
room 101 - booked from 2nd dec - 4th dec.

ive found the function DateDiff() but im not sure if its going to help?

thanks

Mark
Nov 28 '06 #3
NeoPa
32,556 Expert Mod 16PB
excellent cheers.

only probelm is this wont catch bookings made at different dates eg

room 101 - booked from 1st dec - 5th dec
room 101 - booked from 2nd dec - 4th dec.

ive found the function DateDiff() but im not sure if its going to help?

thanks

Mark
Why would it not?
That's what the complicated stuff in the WHERE clause is for.
Do you say that after testing or is it what you'd expect to happen?
Nov 29 '06 #4
yes thanks
was me being silly!
Dec 4 '06 #5

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

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...
5
by: Murphy | last post by:
We are currently looking into the development of an application for booking resources and are researching the available options for recording and tracking these bookings. The possibilities we...
4
by: WiseOwl | 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...
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...
27
by: Josh | last post by:
I work for a small hotel. They don't want to invest in a good front desk program and the paper system that is being used is not working. It is complete chaos at the moment. I want to make a...
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 ...
3
by: Wildster | last post by:
Hi, I have a form in Access 2000 running Windows XP with the following fields: - Booking_ID Date Person_Name Booking_Type 8-9am (y/n checkbox) 9-10am (y/n checkbox)
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...
2
by: rubyhuang | last post by:
Hi, experts: I've got a question that I want to find all the rooms in a given hotel which is unoccupied and I write the query like that, but it cannot work. can anyone help me to figure out? thank...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.