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

Open ended booking system Validation using VBA

Hi,

I am creating a database for my A level project and i am stuck on the validation for the booking part of the database, and was just wondering if anyone could help me out? It is a plumbing booking and stock database in the booking section I have start date, start time and duration field. I want to add validation on the start date field as an after update event. Any ideas would be extremely helpful. Thank you.


Tom
Dec 5 '07 #1
5 2735
please help me i am really stuck and if i can not work out a good way to do it using open ended booking i will have to use booking slots and that is just the easy way out.


Tom
Dec 5 '07 #2
ADezii
8,834 Expert 8TB
Hi,

I am creating a database for my A level project and i am stuck on the validation for the booking part of the database, and was just wondering if anyone could help me out? It is a plumbing booking and stock database in the booking section I have start date, start time and duration field. I want to add validation on the start date field as an after update event. Any ideas would be extremely helpful. Thank you.


Tom
What is the Validation on the Start Date Field that you are looking for and is this Table, Form, or Field Validation?
Dec 5 '07 #3
Its on the start date field in the form to stop double booking, i want something like this

1.
Private Sub ScheduleEndTime_AfterUpdate()
2.
Dim db As DAO.Database
3.
Dim rs As DAO.Recordset
4.
Dim strMessage As String
5.
Dim startTime As Date
6.
Dim endTime As Date
7.
Dim test As Boolean
8.

9.
test = False
10.
If Me.NewRecord = True Then
11.
Set db = CurrentDb
12.
Set rs = db.OpenRecordset("SELECT [ScheduleStartTime], [ScheduleEndTime] " & _
13.
"FROM Schedule INNER JOIN ScheduleDetails " & _
14.
"ON Schedule.ScheduleID=ScheduleDetails.ScheduleID " & _
15.
"WHERE [CourtID]=" & Forms![Bookings]![BookingsSubform].Form![CourtID] & " " & _
16.
"AND [ScheduleDate]=#" & Forms![Bookings]![BookingsSubform].Form![ScheduleDate] & "#")
17.

18.
startTime = Me.ScheduleStartTime
19.
endTime = Me.ScheduleEndTime
20.
If rs.RecordCount = 0 Then Exit Sub
21.
rs.MoveFirst
22.
Do Until rs.EOF
23.
If startTime = rs!ScheduleStartTime Or endTime = rs!ScheduleEndTime Then
24.
test = True
25.
ElseIf startTime > rs!ScheduleStartTime And startTime < rs!ScheduleEndTime Then
26.
test = True
27.
ElseIf endTime < rs!ScheduleEndTime And endTime > rs!ScheduleStartTime Then
28.
test = True
29.
End If
30.
If test Then
31.
rs.MoveLast
32.
End If
33.
rs.MoveNext
34.
Loop
35.

36.
If test = False Then
37.
MsgBox ("Time is available")
38.
Else
39.
MsgBox ("Time is unavailable")
40.
Me.ScheduleStartTime = Null
41.
Me.ScheduleEndTime = Null
42.
End If
43.

44.
rs.Close
45.
Set rs = Nothing
46.
Set db = Nothing
47.

48.
End If
49.

50.
End Sub

from this http://www.thescripts.com/forum/thread604404.html thread but i am not sure how to implement it so it works on mine.

Tom
Dec 5 '07 #4
Hi guys erm i tried to make that code above work in my database but it did not work out very well could anyone tell me what i have done wrong please. By the way it is in the form job* table which is based on the table of the same name.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Start_date_AfterUpdate()
  2.  
  3.  
  4. Dim db As DAO.Database
  5. Dim rs As DAO.Recordset
  6. Dim strMessage As String
  7. Dim startTime As Date
  8. Dim endTime As Date
  9. Dim test As Boolean
  10.  
  11. test = False
  12. If Me.NewRecord = True Then
  13. Set db = CurrentDb
  14.      Set rs = db.OpenRecordset("SELECT [Start_time], [End] " & _
  15.              "FROM Forms![Job* table] " & _
  16.              "ON Forms![job* table].Job_ID " & _
  17.              "WHERE [Job_ID]=" & Forms![Job* table]![Booking] & " " & _
  18.              "AND [Start_Date]=#" & Forms![Job* table].Form![Start_date] & "#")
  19.  
  20. startTime = Me.Start_time
  21. endTime = Me.End
  22. rs.MoveFirst
  23.      Do Until rs.EOF
  24.          If startTime = rs!Start_time Or endTime = rs!End Then
  25.            test = True
  26.          ElseIf Start_time > rs!Start_time And startTime < rs!End Then
  27.            test = True
  28.           ElseIf endTime < rs!End And endTime > rs!Start_time Then
  29.  
  30.  test = True
  31.  
  32.         End If
  33.  
  34.         If test Then
  35.  
  36.           rs.MoveLast
  37.  
  38.         End If
  39.  
  40.         rs.MoveNext
  41.  
  42.     Loop
  43.  
  44.      If test = False Then
  45.        MsgBox ("Time is available")
  46.      Else
  47.        MsgBox ("Time is unavailable")
  48.        Me.Start_time = Null
  49.        Me.End = Null
  50.      End If
  51.  
  52.      rs.Close
  53.      Set rs = Nothing
  54.      Set db = Nothing
  55.  
  56.    End If
  57.  
  58.  End Sub
  59.  
  60.  

Tom
Dec 6 '07 #5
ADezii
8,834 Expert 8TB
Hi guys erm i tried to make that code above work in my database but it did not work out very well could anyone tell me what i have done wrong please. By the way it is in the form job* table which is based on the table of the same name.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Start_date_AfterUpdate()
  2.  
  3.  
  4. Dim db As DAO.Database
  5. Dim rs As DAO.Recordset
  6. Dim strMessage As String
  7. Dim startTime As Date
  8. Dim endTime As Date
  9. Dim test As Boolean
  10.  
  11. test = False
  12. If Me.NewRecord = True Then
  13. Set db = CurrentDb
  14.      Set rs = db.OpenRecordset("SELECT [Start_time], [End] " & _
  15.              "FROM Forms![Job* table] " & _
  16.              "ON Forms![job* table].Job_ID " & _
  17.              "WHERE [Job_ID]=" & Forms![Job* table]![Booking] & " " & _
  18.              "AND [Start_Date]=#" & Forms![Job* table].Form![Start_date] & "#")
  19.  
  20. startTime = Me.Start_time
  21. endTime = Me.End
  22. rs.MoveFirst
  23.      Do Until rs.EOF
  24.          If startTime = rs!Start_time Or endTime = rs!End Then
  25.            test = True
  26.          ElseIf Start_time > rs!Start_time And startTime < rs!End Then
  27.            test = True
  28.           ElseIf endTime < rs!End And endTime > rs!Start_time Then
  29.  
  30.  test = True
  31.  
  32.         End If
  33.  
  34.         If test Then
  35.  
  36.           rs.MoveLast
  37.  
  38.         End If
  39.  
  40.         rs.MoveNext
  41.  
  42.     Loop
  43.  
  44.      If test = False Then
  45.        MsgBox ("Time is available")
  46.      Else
  47.        MsgBox ("Time is unavailable")
  48.        Me.Start_time = Null
  49.        Me.End = Null
  50.      End If
  51.  
  52.      rs.Close
  53.      Set rs = Nothing
  54.      Set db = Nothing
  55.  
  56.    End If
  57.  
  58.  End Sub
  59.  
  60.  

Tom
If test evaluates to True in Lines 25, 27, or 30, a MoveLast was executed in Line #36 and then a MoveNext in Line #40 which will generate an Error. This could happen on the 1st Record in the Recordset before spanning the entire Recordset.
Dec 6 '07 #6

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

Similar topics

2
by: PaulD | last post by:
Can anyone point me in the direction of a sample Access booking system? Trying to build a booking system were customers can book a computer by date and timeslot, each timeslot having a limited...
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...
3
by: 4004 | last post by:
I would be grateful for help with the following: For a booking system tblBook(BookedItemId,DateBooked) tblBookingPeriodAllowed(PeriodName, PeriodStartDate, PeriodEndDate) I want:
1
by: samkut | last post by:
Hi, we are looking for a slim open source course booking system with the following features: * users can enroll for courses, cancel their bookings * maximum number of participants *...
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...
5
by: Peter Sutton | last post by:
Greetings all, My booking system includes 2 tables: tblRooms with the key field RoomID, and some other fields AND a tblBooked Rooms with a number of fields including RoomID and BookedDate. ...
3
by: 88stevie | last post by:
Hi all, I have a system and I'm a little stuck. It's a booking system. It has rooms, etc and every room have a daily price. Then it has special daily rates when assigned. How do I...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.