473,785 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hotel booking (double bookings)

14 New Member
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_d ate and booking_end_dat e

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_Numbe r = " & Me!Room_Number

Me.RecordsetClo ne.MoveFirst
Me.RecordsetClo ne.FindFirst strWhere

Do Until Me.RecordsetClo ne.nomatch
If Me.RecordsetClo ne!Room_Numnber = Me!Room_Number Then
MsgBox ("test")
Cancel = True
Exit Sub
End If
Me.RecordsetClo ne.FindNext strWhere
Loop
End If
Nov 28 '06 #1
4 2770
NeoPa
32,578 Recognized Expert Moderator MVP
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
markymark34
14 New Member
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,578 Recognized Expert Moderator MVP
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
markymark34
14 New Member
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
18693
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 bit I'm struggling with is checking the Room Availability based on dates that are typed into a textfield and then returning a list of the available rooms on the next page. The three tables involved in this function are: CREATE TABLE `room` (
5
1468
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 have presently for managing and tracking bookings are: a) Store bookings in SQL db and code the calendar functionality, showing existing bookings & availability b) Interface with Exchange c) Utilise a 3rd party product
4
3254
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 group, subject and software) and analysis of bookings is a nightmare. I just fancied pottering with Access, which I am pretty familiar with, to see if I could create a means of booking a room using a database. Locking a booking would then be a...
2
8240
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 group, subject and software) and analysis of bookings is a nightmare. I just fancied pottering with Access, which I am pretty familiar with, to see if I could create a means of booking a room using a database. Locking a booking would then be a...
27
2980
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 database or program that will be able to manage the guest register and reservations. It doesn't have to handle payments at this stage. Preventing overbookings is a critical priority at the moment because it is going into high season here in Florida....
25
2866
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 tblPersonaldetails -- -Autonumber, etc tblOutingDetails -- -Autonumber, etc
3
3660
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
4660
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 particular truck so that when a new entry is being added, if the LoadDate and LoadTime doubles up with an existing entry I can flag it to the user?
2
3286
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 you and waiting for your reply. the schema for the four tables look like that hotel(hotelNo,hotelName,city) room(roomNo,hotelNo,type,price) booking(hotelNo,guestNo,dateFrom,dateTo,roomNo) guest(guestNo,guestName,guestAddress) select roomNo,...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.