G
Guest
Hi all, (bit long i'm sorry
I've posted this before (on the forms page) but i think i may have more success here (no offence to the other MVP's
I am trying to create a query that will check the values entered into a forms combo boxes AGAINST a booking table and check to see if there are any duplicate entries
Easy and i've done this bit -
The hard bit is that i need to be able to distinguish between mulitple hire times for one aircraft within a given date
ie an aircraft "G-BGIY" on [HireDate] can be booked between the hours of #09:00:00# and #10:00:00# but also between #12:00:00# and #13:00:00# - how do i change the following code to allow these two bookings to occur?
--------Code is--------
Private Sub ConfirmBooking_Click(
Dim strSql As Strin
Dim rstFound As DAO.Recordse
strSql = "Select AcReg FROM BookingDetails where [AcReg] = '" & cboAcReg & "'"
& " AND ([HireDate] = #" & cboHireDate & "# "
& " AND [StartTime] >= #" & cboStartTime & "# AND [EndTime] <= #" & cboEndTime & "#)
Set rstFound = CurrentDb.OpenRecordset(strSql
If rstFound.RecordCount > 0 The
Call MsgBox("Sorry this aircraft is already booked, please choose another time", vbCritical, "Error")
Els
Call MsgBox("Your booking is confirmed", vbExclamation, "Booking Confirmed"
DoCmd.GoToRecord , , acNewRe
End I
End Su
--------TABLES---------
tbl BookingDetails
AcRe
HireDat
StartTim
EndTIm
------QUERY-------
SELECT BookingDetails.MemberNo, BookingDetails.AcReg, BookingDetails.HireDate, BookingDetails.StartTime, BookingDetails.EndTim
FROM BookingDetails
This is the query i want to use the given code to find any duplicates from - at the moment it seems to get stuck on the HireDate field and will not allow 2 entries for the same day
Thanks in advance
Cam
I've posted this before (on the forms page) but i think i may have more success here (no offence to the other MVP's
I am trying to create a query that will check the values entered into a forms combo boxes AGAINST a booking table and check to see if there are any duplicate entries
Easy and i've done this bit -
The hard bit is that i need to be able to distinguish between mulitple hire times for one aircraft within a given date
ie an aircraft "G-BGIY" on [HireDate] can be booked between the hours of #09:00:00# and #10:00:00# but also between #12:00:00# and #13:00:00# - how do i change the following code to allow these two bookings to occur?
--------Code is--------
Private Sub ConfirmBooking_Click(
Dim strSql As Strin
Dim rstFound As DAO.Recordse
strSql = "Select AcReg FROM BookingDetails where [AcReg] = '" & cboAcReg & "'"
& " AND ([HireDate] = #" & cboHireDate & "# "
& " AND [StartTime] >= #" & cboStartTime & "# AND [EndTime] <= #" & cboEndTime & "#)
Set rstFound = CurrentDb.OpenRecordset(strSql
If rstFound.RecordCount > 0 The
Call MsgBox("Sorry this aircraft is already booked, please choose another time", vbCritical, "Error")
Els
Call MsgBox("Your booking is confirmed", vbExclamation, "Booking Confirmed"
DoCmd.GoToRecord , , acNewRe
End I
End Su
--------TABLES---------
tbl BookingDetails
AcRe
HireDat
StartTim
EndTIm
------QUERY-------
SELECT BookingDetails.MemberNo, BookingDetails.AcReg, BookingDetails.HireDate, BookingDetails.StartTime, BookingDetails.EndTim
FROM BookingDetails
This is the query i want to use the given code to find any duplicates from - at the moment it seems to get stuck on the HireDate field and will not allow 2 entries for the same day
Thanks in advance
Cam