473,466 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Equipment Booking

10 New Member
Hi

I am curently doing an access data base to book audiovisual equipments. I have used index to have date, equipmet and startTime as primary key that way I dont book the same equipment twice. But am lost with the ReturnTime because if the equipment is out from 8am to 11am it lets me book from 9am to 10am for example. My times are selected from combobox which are fed by tables. My tables are the following.

tblUserInfo
ID_PR(primary key)
UserName
UserID

tblLoanInfo
ID_SC(primary key)
ID_PR
LoanDate
Equipment
StartTime
EndTime

tblEquipment
Equipment

tblStartTime
StartTime

tblReturnTime
ReturnTime


I have a frmLoan with the user information and the loanInfo subform with the loan date, equipment, starttime and endtime. I am stuck trying to figure out how to prevent double booking for time gaps.
Jan 25 '10 #1
16 3108
nico5038
3,080 Recognized Expert Specialist
As you found out, the starttime in the index won't work.
When inserting a new appointment you'll need to test or for this equipment ID there's an overlap with an existing booking.

An alternative might be to "translate" the times of a day into 24 red/green colored text boxes. Thus the availability is also visualized and when you really want it flexible, even the time selection could be done with the "OnClick" on these boxes...

Nic;o)
Jan 25 '10 #2
cadillac
10 New Member
Thanks for the info nico. I am trying to find a way that after I select the date and equipment, and selecting the starttime a code can verify if the selected starttime is >= than the returntime. I have a query that pulls out the date and equipment from the form, just lost on how to do the comparison.
Jan 26 '10 #3
cadillac
10 New Member
I have done a qry to find overlap time and see double booking. I need some help on how to use the qry to prevent such events. The qry looks like this.
Expand|Select|Wrap|Line Numbers
  1. SELECT tblloaninfo.LoanDate, tblloaninfo.EquipmentID, tblloaninfo.StartTime, tblloaninfo.Returntime, tblloaninfo_1.LoanDate, tblloaninfo_1.EquipmentID, tblloaninfo_1.StartTime, tblloaninfo_1.Returntime, ([tblloaninfo_1].[Starttime]>=[tblloaninfo].[Returntime]) Or ([tblloaninfo_1].[Returntime]<=[tblloaninfo].[Starttime]) Or ([tblloaninfo].[ID_SC]=[tblloaninfo_1].[ID_SC]) AS NoClash
  2. FROM tblloaninfo, tblloaninfo AS tblloaninfo_1
  3. WHERE (((tblloaninfo.LoanDate)=[Forms]![frmLoan]![loaninfo Subform].[Form]![loandate]) AND ((tblloaninfo.EquipmentID)=[Forms]![frmLoan]![loaninfo Subform].[Form]![EquipmentID]) AND ((tblloaninfo_1.LoanDate)=[Forms]![frmLoan]![loaninfo Subform].[Form]![loandate]) AND ((tblloaninfo_1.EquipmentID)=[Forms]![frmLoan]![loaninfo Subform].[Form]![EquipmentID]) AND ((([tblloaninfo_1].[Starttime]>=[tblloaninfo].[Returntime]) Or ([tblloaninfo_1].[Returntime]<=[tblloaninfo].[Starttime]) Or ([tblloaninfo].[ID_SC]=[tblloaninfo_1].[ID_SC]))=False))
  4. ORDER BY tblloaninfo.StartTime;
  5.  
any ideas...
Jan 26 '10 #4
nico5038
3,080 Recognized Expert Specialist
You'll need to test the double booking on your form, thus I would propose to use an IF statement using a DLOOKUP like:
Expand|Select|Wrap|Line Numbers
  1. IF ISNULL(DLOOKUP("EquipmentID","tblloaninfo","#" & Me.Loandate & " " & Me.StartTime & "# < Loandate + Returntime AND #" & Me.Loandate & " " & Me.Returntime & "# > Loandate + StartTime)") then
  2.    ' No match action
  3. else
  4.    ' match action
  5. endif
  6.  
The test is to find an overlap from the period with an existing period. This is done by first concatenating the date and time from the form and by adding the date and time of the table.
When the form's startdate is before the enddatetime of a record and the returndate is after the startdatetime from the record, than a record is found and thus inserting this booking isn't possible.

Getting the idea ?

Nic;o)
Jan 26 '10 #5
cadillac
10 New Member
I have been working with these two and can not get one to work. Help please...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Returntime_AfterUpdate()
  2. If Not IsNull(DLookup("[EquipmentID]", "tblloaninfo", "[Starttime] >= #" & Me.
  3. Returntime & "#AND [Returntime] <= #" & Me.StartTime & "#")) Then
  4.   MsgBox Me.EquipmentID & " is booked for the selected time, please select
  5. another Equipment or time!", vbOKOnly
  6. Else
  7.   DoCmd.RunCommand acCmdSaveRecord
  8. End If
  9. End Sub
and I also found this one and gave it a try

Expand|Select|Wrap|Line Numbers
  1. Private Sub Returntime_AfterUpdate()
  2. Dim strWhere As String
  3.   Dim varResult As Variant
  4.   Dim strMsg As String
  5.   Const strcJetDateTime = "\#mm\/dd\/yyyy hh\:nn\:ss\#"
  6.  
  7.   If ((Me.StartTime = Me.StartTime.OldValue) And (Me.Returntime = Me.
  8. Returntime.OldValue) And (Me.EquipmentID = Me.EqipmentID.OldValue)) Or IsNull
  9. (Me.StartTime) Or IsNull(Me.Returntime) Or IsNull(Me.EquipmentID) Then
  10.           'do nothing
  11.   Else
  12.       strWhere = "(StartTime < " & Format(Me.Returntime, strcJetDateTime) &
  13. ")" AND " & Format(Me.StartTime, strcJetDateTime) & " < ReturnTime) AND
  14. (EquipmentID = " & Me.EquipmentID & ")"
  15. Debug.Print strWhere
  16.       varResult = DLookup("ID_SC", "tblloaninfo", strWhere)
  17.       If Not IsNull(varResult) Then
  18.           strMsg = "Clashes with booking # " & varResult & vbCrLf &
  19. "Continue anyway?"
  20.           If MsgBox(strMsg, vbYesNo + vbDefaultButton2, "Double-booked") <>
  21. vbYes Then
  22.               Cancel = True
  23.           End If
  24.       End If
  25.   End If
  26.  
  27. End Sub


thank you for you help...
Jan 27 '10 #6
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi Cadillac. Please use the code tags we provide so that your code is easier to read.

Telling us that something does not work is not much of a clue. What do the two routines you have tried do when you try them? Unless you can be specific we can't help you, as we are not in a position to understand the exact context in which you are using your data. Give us examples of the bookings involved.

When I've done similar applications (for booking classrooms at particular times, seeking to avoid clashes with other bookings) I have written out the combinations that are possible and shown them on a time-line, then worked out from these notes the conditional tests needed to ensure that the bookings do not clash. You may well need to do the same.

To give you some idea of whats involved, if you have a definite booking for a piece of AV equipment between a particular startdate-time and enddate-time then no other booking for that piece of equipment can be made where:

(1) the start time for the new booking is between an existing booking startdate-time value and the enddate-time value, or

(2) the enddate-time value of the new booking is between an existing startdate-time value of the existing booking and the enddate-time value of that booking, or

(3) the startdate-time value of the new booking is less than the startdate-time value of an existing booking and the enddate-time value of the new booking is greater than the enddate-time value of an existing booking

To put it another way, you can't allow equipment bookings starting or ending within a current booking period, or bookings which encompass the whole of an existing booking.

If an item is out and the booking for it is still 'open' - no end date-time recorded - then that is something else you will have to take into account in applying these tests.

-Stewart
Jan 27 '10 #7
nico5038
3,080 Recognized Expert Specialist
In both "solutions" there's no date compared, thus it won't work.
Comparing with the .OldValue is only interestiung when you change data on a form, and you need to compare with al records...

Please check my proposed solution again.

Nic;o)
Jan 27 '10 #8
cadillac
10 New Member
I was thinking that taking the posible booking values from the form, compare them to the tables and if there was no clash then save to table. Going back to your code I get an error. The debug gives me this line in red.

IF ISNULL(DLOOKUP("EquipmentID","tblloaninfo","#" & Me.Loandate & " " & Me.StartTime & "# < Loandate + Returntime AND #" & Me.Loandate & " " & Me.Returntime & "# > Loandate + StartTime)") then

thanks for your help...
Jan 27 '10 #9
nico5038
3,080 Recognized Expert Specialist
Can you make a .zip with a sampe .mdb with the table and some testdate, thus I can check the error.
Just use the [Go Advanced] button to add an attachment.

Nic;o)
Jan 27 '10 #10
cadillac
10 New Member
Once again thanks Nico for your help. Here is a copy of my sample data base. There you will see a qry named qrybookingclash which shows my double bookings also I have a qrybooking which lets me see the booking all have a criteria that takes the date and equipment from the open frmLoan. I am desperate to get the double booking posibility out. I will appreciate all you can do to help. Thank you.
Attached Files
File Type: zip Equipment Booking.zip (145.6 KB, 124 views)
Jan 27 '10 #11
nico5038
3,080 Recognized Expert Specialist
OK here a working sample, I embedded the DLOOKUP and corrected the erroneous ")". Also added the EquipmentIS and ID_SC to make the DLOOKUP 100%.
The test has been placed in a separate sub, as it needs to be executed after a change of either time combo.
Also added a switch to control the cancellation of the update when no overlap is allowed by the user.

Nic;o)
Attached Files
File Type: zip Equipment Booking nico5038.zip (41.3 KB, 166 views)
Jan 27 '10 #12
cadillac
10 New Member
Thank very much for all your help. I really appreciate all you have done to help me out. The Dlookup works 100% just as say.
Jan 28 '10 #13
cadillac
10 New Member
I dont know if its to much to ask but can it be possible for you to tell me how to change the option of the Double-Booked button options. I dont want to mess it up, since its working perfectly. What i would like it for to change the pop up message from yes no options to one. In other words eliminate the option to answer a yes to continue any way.

Else
strMsg = "Clashes with booking times: " & DLookup("[Starttime] & ' / ' & [Returntime]", "tblloaninfo", "#" & Me.LoanDate & " " & Me.StartTime & "# < Loandate + Returntime AND #" & Me.LoanDate & " " & Me.Returntime & "# > Loandate + StartTime AND EquipmentID='" & Me.EquipmentID & "'") & vbCrLf & "Continue anyway?"
If MsgBox(strMsg, vbYesNo + vbDefaultButton2, "Double-booked") = vbNo
Then
switchOverlap = True
End If
Jan 28 '10 #14
cadillac
10 New Member
Nico
I went ahead a gave it a try and I got it working like I had asked. Can you give it a look to see if the changes are ok...

Else
strMsg = "Clashes with booking times: " & DLookup("[Starttime] & ' / ' & [Returntime]", "tblloaninfo", "#" & Me.LoanDate & " " & Me.StartTime & "# < Loandate + Returntime AND #" & Me.LoanDate & " " & Me.Returntime & "# > Loandate + StartTime AND EquipmentID='" & Me.EquipmentID & "'")
If MsgBox("Double-booked") = vbOK
Then
switchOverlap = True
End If
Jan 28 '10 #15
nico5038
3,080 Recognized Expert Specialist
You don't need to use the "IF" for the messagebox, as an answer isn't needed and just a "msgbox strMsg" will do.
Just keep setting the "switchOverlap = True" when there's an overlap to reset the data when the user navigates to another record as tested in the "IF DLOOKUP".

Nic;o)
Jan 28 '10 #16
cadillac
10 New Member
Thanks for the information.
Jan 28 '10 #17

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...
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...
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...
20
by: bredal Jensen | last post by:
Hello gurus, I'm building a small booking system and i have come accross quiet a tedious pitfall. "I need to make sure that people do not book for tomorrow when todays time is greater or...
0
by: wjadoon | last post by:
JUNCTION TRADER INC. I N T E R N A T I O N A L I N C . 81-33 164 PL. Jamaica New York 11432 USA. Ph: 516 707 5000 www.junctiontrader.com Dear Sir:
0
by: thegame21 | last post by:
Hi, I am currently creating a cinema system using access where a booking can be made for a event. Each event when it is shown is categoriesd as a performance. A booking must be made for each...
1
by: simba | last post by:
Hello, I am currently doing a project which requires me to develop an online booking system for hotels and integrate both bed and room booking. I have the room booking working but I cant seem to...
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 ...
7
by: phill86 | last post by:
Hi, I have an equipment booking form that a user is able to book a piece of equipment on a selected date and time. I have written code to prevent the user being able to book the piece of equipment...
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
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.