I'm very new to vba code, so new that i find it hard to follow tutorials, i found this link in this website to prevent double bookings: http://bytes.com/topic/access/answer...ouble-bookings
I created a form and created a button called "make booking" in this form, where i pasted this code that i got on the link in the "onclick" tab of the event menu in the property sheet:
i get an expression error. I am not sure what I have done wrong, is it that I have put the code in the wrong area? if so where should I put it? I also need to know if the field "Reservatio n In Date" can be written as "Reservatio n In Date"or should i put it as "Reservation_In _Date" in the code, thanks for ur time:)
I created a form and created a button called "make booking" in this form, where i pasted this code that i got on the link in the "onclick" tab of the event menu in the property sheet:
Code:
Private Sub Book_Click()
If Me.NewRecord = True Then
Dim strWhere As String, strMessage As String
Dim rsClone As Recordset
strWhere = "((Room No=" & Me.Room No & _
") AND (Reservation Out Date>=#" & _
Format(Me.Reservation In Date, "m/d/yyyy") & _
"#) AND (Reservation In Date<=#" & _
Format(Me.Reservation Out Date, "m/d/yyyy") & _
"#))"
Set rsClone = Me.RecordsetClone
rsClone.MoveFirst
rsClone.FindFirst strWhere
If rsClone.NoMatch Then
MsgBox ("test")
Cancel = True
Exit Sub
End If
End If
End Sub
Comment