473,327 Members | 2,112 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,327 software developers and data experts.

Double Bookings

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

Apr 3 '07 #1
6 2535
On Apr 3, 5:35 pm, iazah...@hotmail.com wrote:
I use Access 2000 and I'm trying to figure out what VBA code to use to
prevent double bookings. The system I am trying to creating is a booking system for a car park.
Any help on this matter will be greatly
appreciated. Regards Immy
Apr 3 '07 #2
Define "double booking". Show the structure of tables. Show sample
input with expected output. Here's some vba that may (probably
not...) help.

public sub JasonsSolution()
msgbox "Give more information!"
end sub

I know it doesn't work but it's the best I could come up with such
limited information.

After you give more info you could be helped.

Cheers,
Jason Lepack

On Apr 3, 12:35 pm, iazah...@hotmail.com wrote:
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

Apr 3 '07 #3
On Apr 3, 5:41 pm, "Immy" <iazah...@hotmail.comwrote:
On Apr 3, 5:35 pm, iazah...@hotmail.com wrote:
I use Access 2000 and I'm trying to figure out what VBA code to use to
prevent double bookings. The system I am trying to creating is a booking system for a car park.

Any help on this matter will be greatly
appreciated. Regards Immy- Hide quoted text -

- Show quoted text -
I would also like to add that the problem I keep having is how to
prevent two people from booking the same parking space on the same
date. Immy
Apr 3 '07 #4
On Apr 3, 5:43 pm, "Jason Lepack" <jlep...@gmail.comwrote:
Define "double booking". Show the structure of tables. Show sample
input with expected output. Here's some vba that may (probably
not...) help.

public sub JasonsSolution()
msgbox "Give more information!"
end sub

I know it doesn't work but it's the best I could come up with such
limited information.

After you give more info you could be helped.

Cheers,
Jason Lepack

On Apr 3, 12:35 pm, iazah...@hotmail.com wrote:
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- Hide quoted text -

- Show quoted text -
Tables are as follows
Customer
- No.
Title, First Name, Surname, House No, Street, Town,
County, Post Code, tel no.
Boat
-No.
-Name
Parking Space
- no. and Location
Bookings
No, Cust no, Boat No, Parking Space no, Date from and
Date to.

Is this of any help?

Apr 3 '07 #5
On Apr 3, 5:43 pm, "Jason Lepack" <jlep...@gmail.comwrote:
Define "double booking". Show the structure of tables. Show sample
input with expected output. Here's some vba that may (probably
not...) help.

public sub JasonsSolution()
msgbox "Give more information!"
end sub

I know it doesn't work but it's the best I could come up with such
limited information.

After you give more info you could be helped.

Cheers,
Jason Lepack

On Apr 3, 12:35 pm, iazah...@hotmail.com wrote:
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- Hide quoted text -

- Show quoted text -
This is the code I'm using at the min and it dont work:
Private Sub Command26_Click()
On Error GoTo Err_Command26_Click

Dim strSQL As String
Dim intCount As Integer
strSQL = "[Parking Space No] = " & [Parking Space No] & "" _
& "AND [DateFrom] = #" & [DateFrom] & "#" _
& "AND [DateTo] = #" & [DateTo] & "#"
intCount = DCount("[Parking Space No]", "Parking Space", strSQL)

If intCount = 0 Then 'slot is free
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
cmdNew.SetFocus
' Command26.Enabled = False
Calendar2.Enabled = False
myDisplayInfoMessage = "Booking Confirmed"

Else
myDisplayWarningMessage = "This has already been booked" & vbCrLf
_
& "Please choose another"

End If

Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click

End Sub

Apr 3 '07 #6
'Try this instead:

Private Sub Command26_Click()
On Error GoTo Err_Command26_Click

Dim strSQL As String
Dim intCount As Integer
Dim rs As Recordset

' This gets a count of all records in Bookings that have the given
parking space number
' and one of it's dates between the two new dates
strSQL = " SELECT count([Booking No]) AS C " _
& "FROM Bookings " _
& "WHERE (DateTo BETWEEN #" & [DateFrom] & "# AND #" &
[DateTo] & "# " _
& " OR DateFrom BETWEEN #" & [DateFrom] & "# AND #" &
[DateTo] & "#) " _
& " AND [Parking Space No] = " & [Parking Space No]
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveFirst
If rs!C = 0 Then 'slot is free
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
cmdNew.SetFocus
' Command26.Enabled = False
Calendar2.Enabled = False
myDisplayInfoMessage = "Booking Confirmed"
Else
myDisplayWarningMessage = "This has already been booked" & vbCrLf
_
& "Please choose another"
End If
Set rs = Nothing
Exit_Command26_Click:
Exit Sub
Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click
End Sub

On Apr 3, 12:51 pm, "Immy" <iazah...@hotmail.comwrote:
On Apr 3, 5:43 pm, "Jason Lepack" <jlep...@gmail.comwrote:


Define "double booking". Show the structure of tables. Show sample
input with expected output. Here's some vba that may (probably
not...) help.
public sub JasonsSolution()
msgbox "Give more information!"
end sub
I know it doesn't work but it's the best I could come up with such
limited information.
After you give more info you could be helped.
Cheers,
Jason Lepack
On Apr 3, 12:35 pm, iazah...@hotmail.com wrote:
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- Hide quoted text -
- Show quoted text -

This is the code I'm using at the min and it dont work:
Private Sub Command26_Click()
On Error GoTo Err_Command26_Click

Dim strSQL As String
Dim intCount As Integer
strSQL = "[Parking Space No] = " & [Parking Space No] & "" _
& "AND [DateFrom] = #" & [DateFrom] & "#" _
& "AND [DateTo] = #" & [DateTo] & "#"
intCount = DCount("[Parking Space No]", "Parking Space", strSQL)

If intCount = 0 Then 'slot is free

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
cmdNew.SetFocus
' Command26.Enabled = False
Calendar2.Enabled = False
myDisplayInfoMessage = "Booking Confirmed"

Else
myDisplayWarningMessage = "This has already been booked" & vbCrLf
_
& "Please choose another"

End If

Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click

End Sub- Hide quoted text -

- Show quoted text -

Apr 3 '07 #7

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

Similar topics

6
by: Dan Evans | last post by:
Hi, Can anyone help me on a little problem I am having with some SQL - in particular on a subquery. I am setting up a database in Access for a voluntary group which runs
12
by: Sydex | last post by:
When I compile code I get error C2664: 'Integration::qgaus' : cannot convert parameter 1 from 'double (double)' to 'double (__cdecl *)(double)' in this part : double Integration::quad2d(double...
2
by: Brian O'Gorman | last post by:
I have: a) a calendar table (tblCalendar) holding consecutive dates. b) a vacancies table (tblVacancies) holding start and end dates of vacancies c) a bookings table (tblBookings holding start...
8
by: Mike Jolley | last post by:
Hello First off, I'm a student so I'm pretty new to C++, and therefore I have probably made a stupid mistake somewhere. Anyway Ive been trying to fix this 5 hours straight now, so i need a...
6
by: Jim Devenish | last post by:
I have an unbound form that displays all the days of the year as a calendar. It has 12 rows of text boxes with either 29,30 or 31 in each row. Text box names are of the form: display_01_01,...
9
Jacotheron
by: Jacotheron | last post by:
For one of my clients I must make an internet bookings page. The script must view all bookings that is happening in the future and it must accept new bookings entries that may be added by the viewer...
0
by: Yew12 | last post by:
I'm trying to use PL/SQL to create a trigger that will stop bookings. Based on a duration field and a start time. I have had a go at trying to do this but I'm sure that im well off from where I...
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...
4
by: phill86 | last post by:
Hi, I am trying to represent on a form time slots I have re-created the look of an outlook calendar on the form I have a table with the calendar bookings start and end time and there could be any...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.