Error in code - Double Booking

coolcatkelso

Registered User.
Local time
Today, 08:05
Joined
Jan 5, 2009
Messages
279
Hiya guys

Been trying to finx this double booking issue since 1am lol

Here is the code

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Result As Long
If IsNull(Me.fldDate) Then
   MsgBox ("Must enter Date.")
   Exit Sub
End If

Result = Nz(DLookup("[FldDate]", "BookingForm", _
         "[FldDate] = " & Me.fldDate & " And " & _
         "[TimeTo] = " & Me.TimeTo), 0)
If Result > 0 Then
   MsgBox ("That time is booked for that day.")
End If
End Sub

The object is to prevent double booking on the time part on the same day

Getting an error on this -
Syntax Error (Missing Operator) in query expression '[FldDate] = 08/01/2010 And [Timeto] ='.

I did some googling and found that code but can't get it to work

The form is based on a table - BookingForm with the following fields

BookingID
FldDate
CustomerID
EmployeeID
TimeFrom (Combo Box with 7:30am - 6.30pm)
TimeTo (Same as above)

Need to prevent a duplicate time slot on the same day, I can change the table to Not allow duplicate on the times which appears to work fine, but then you get that MS msg telling you it cant save as dups not allowed.. Don't know if its easier trying to change that message

Any help?

Been looking all over the net but not having much luck
________
Honda RC211V specifications
 
Last edited:
You need to format the date as mm/dd/yyyy.
Replace "[FldDate] = " & Me.fldDate & " And " & _
with "[FldDate] = #" & Format(Me.fldDate , "mm/dd/yyyy") & "#" & " And " & _
 

Users who are viewing this thread

Back
Top Bottom