Hello!
I need a bit of help, I'm making a database based on a beautician's spa.
Basically, I want to use VBA (or queries, if necessary) to check that an appointment isn't already confirmed for a particular appointment.
At the minute, I have a query which contains:
Date of appointment (Format: Date/Time)
Time of appointment (Format: Lookup wizard, so text).
Basically, I have a command button at the minute, which when clicked, should look through the query and perform a count function. This is meant to count the number of fields where the value of both the date AND time are the same as that which is currently entered.
The code is:
However, I'm hopeless with code. This was taken from a code online, and I don't know how to manipulate it to work for my database. If I click the command button, the error is:
If I have left any information out, please tell me!
Many thanks in advance.
I need a bit of help, I'm making a database based on a beautician's spa.
Basically, I want to use VBA (or queries, if necessary) to check that an appointment isn't already confirmed for a particular appointment.
At the minute, I have a query which contains:
Date of appointment (Format: Date/Time)
Time of appointment (Format: Lookup wizard, so text).
Basically, I have a command button at the minute, which when clicked, should look through the query and perform a count function. This is meant to count the number of fields where the value of both the date AND time are the same as that which is currently entered.
The code is:
Code:
If DCount("*", "QRYDuplicates", "Time of Session=#" & Me.Time_of_session & " And Date_of_appointment=#" & Me.Date_of_Appointment & "#") > 0 Then
MsgBox "Sorry, this is taken!", , "Double Booking"
Else
MsgBox "This appointment is available!", , "Appointment Available"
End If
However, I'm hopeless with code. This was taken from a code online, and I don't know how to manipulate it to work for my database. If I click the command button, the error is:
Run-time error '3075':- Syntax error in date in query expression 'Time of session=# And Date of appointment=##'.
If I have left any information out, please tell me!

Many thanks in advance.