jazzymay
11-14-2008, 06:25 AM
I am doing a project for school and have designed a Database for a Hairdressers where a client can book an appointment with a certain employee and choose the treatment type. I have a start time and an end time.
I would like for that employee not to be able to be booked for at least 30 minutes after the start time of an appointment but my system is letting me do this.
I cannot book that employee for an exact matching appoinment like 10:00 to 11:00 but could book from 10:00 to 10:10.
I was thinking of putting a validation rule at the end time [End Time]>[Start Time]+30 obviously not working as i keep getting this error.
Invalid SQL Syntax - cannot use multiple columns in a column level - CHECK constraint
Please help!!!!!!!!!
mikebaldam
11-19-2008, 01:47 AM
Take a look at the DateAdd function... open your database and press F1 for help and it gives a list of examples including how to add (or subtract a time period)
i.e.
DateAdd("h", 1, [Start Time])
will display a date/time 1 hour after the start time.
jazzymay
11-21-2008, 06:46 AM
This won't work either keeps coming up with the parameter box. Then a syntax error. Won't let me bypass the start time to put in any time in the end time. :confused:
Was thinking of putting a save button on the form with 2 invisable combo boxes holding the following code.
Private Sub Combo16_Change()
previous_booking.Requery
next_booking.Requery
End Sub
Private Sub Combo16_LostFocus()
previous_booking.Requery
next_booking.Requery
End Sub
I have then used a command button for my save button and attached the following code.
Private Sub save_record_Click()
On Error GoTo Err_save_record_Click
Dim before, after As Integer
If previous_booking.ItemData(0) <> "" Then
before = DateDiff("h", previous_booking.ItemData(0), Start_Time)
End If
If next_booking.ItemData(0) <> "" Then
after = DateDiff("h", End_Time, next_booking.ItemData(0))
End If
If before >= 0 And after >= 0 Then
DoCmd.GoToRecord , , acNewRec
Else
If before < 0 Then
MsgBox ("The Limo will still be out on a job at this time!")
End If
If after < 0 Then
MsgBox (" Someone has booked this limo before it is due back!")
End If
End If
Please someone help this is so frustrating. I would love to be able to do databases with no problem, i try and try everything until i can try no more. :(
mikebaldam
11-21-2008, 07:14 AM
Whats the error no/message you get ?
jazzymay
11-23-2008, 03:13 PM
The message reads
Invalid SQL Syntax - cannot use multiple columns in a column level - CHECK constraint
I don't even know what this means, never mind trying to fix it.
I have been putting the DateAdd("h",1,[Start Time]) into the End Time validation rule. But it keeps coming up with this error.
The table is the appointment table which looks like this:
* are my primary keys
* Date
Start Time
End Time
Customer ID
*Employee ID
Treatment Type
I also have an Employee table a Customer table and a treatment table
mikebaldam
11-23-2008, 10:57 PM
Hmmm....
Ok here is what microsoft say about it http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.access.formscodin g&tid=381f6860-cd15-4d29-94d2-e3d6676d340f&cat=&lang=&cr=&sloc=&p=1.
Can you post your MDB (stripped down) ?
jazzymay
11-24-2008, 06:30 AM
I have sent this database as an attachment
The_Doc_Man
11-24-2008, 08:25 AM
Search this forum for the topics "Reservations" and "Bookings" and "Scheduling" - and note that for the latter, you will also get some hits you don't want in this case. Scheduling also covers the topic of running a particular task at a particular time.
You will see numerous threads that discuss various aspects of this problem.