L
Lorenzo
Hello there,
I am using the great looking calendar in a small application for checking
availability on apartments.
I have a function that performs a check on the taken dates triggered by the
BeforeUpdate event, it works normally if I type in the dates, giving me an
error message if I have those dates already taken but it does not do
anything if I use the double click pop up calendar! I don't know why it
looks like it does not feel the event triggered. I have tried to work it
around setting the trigger on the lostfocus but it is not what I want to
achieve.
Another question if the copywrights are not in danger and the change of the
code as well. I would like to color the taken dates that I have for that
apartment
in a similar way the select range of dates does. In this case though has to
be a permanent background color.
the code is the following
Private Function CheckDeparture()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim dteRequest As Date
Dim dteRequest1 As Date
Dim dteStart As Date
Dim dteEnd As Date
Dim strSQL As String
Dim intSelection As Integer
intSelection = CasellaCombinata10
dteRequest1 = dtArrival.Value
dteRequest = dtDeparture.Text
strSQL = "Select [dtArrival], [dtDeparture] FROM tblAvail "
strSQL = strSQL & "WHERE [IDApt] >= " & intSelection
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
rs.MoveFirst
Do While True
With rs
dteStart = rs!dtArrival
dteEnd = rs!dtDeparture
If (dteRequest >= dteStart) And (dteRequest <= dteEnd) Then
MsgBox "The Specified Date " & dteRequest _
& vbCrLf & "for " & CasellaCombinata10.Column(1) & _
" Is not available until " & dteStart - 1
DoCmd.CancelEvent
Exit Function
End If
If (dteStart > dteRequest1) And ((dteEnd < dteRequest) And
(dteRequest > dteStart)) Then
MsgBox "Date Range Already Booked " & _
vbCrLf & dteStart & " Thru " & dteEnd
DoCmd.CancelEvent
Exit Function
End If
End With
rs.MoveNext
Loop
End Function
Thanks in advance
Lorenzo
I am using the great looking calendar in a small application for checking
availability on apartments.
I have a function that performs a check on the taken dates triggered by the
BeforeUpdate event, it works normally if I type in the dates, giving me an
error message if I have those dates already taken but it does not do
anything if I use the double click pop up calendar! I don't know why it
looks like it does not feel the event triggered. I have tried to work it
around setting the trigger on the lostfocus but it is not what I want to
achieve.
Another question if the copywrights are not in danger and the change of the
code as well. I would like to color the taken dates that I have for that
apartment
in a similar way the select range of dates does. In this case though has to
be a permanent background color.
the code is the following
Private Function CheckDeparture()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim dteRequest As Date
Dim dteRequest1 As Date
Dim dteStart As Date
Dim dteEnd As Date
Dim strSQL As String
Dim intSelection As Integer
intSelection = CasellaCombinata10
dteRequest1 = dtArrival.Value
dteRequest = dtDeparture.Text
strSQL = "Select [dtArrival], [dtDeparture] FROM tblAvail "
strSQL = strSQL & "WHERE [IDApt] >= " & intSelection
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
rs.MoveFirst
Do While True
With rs
dteStart = rs!dtArrival
dteEnd = rs!dtDeparture
If (dteRequest >= dteStart) And (dteRequest <= dteEnd) Then
MsgBox "The Specified Date " & dteRequest _
& vbCrLf & "for " & CasellaCombinata10.Column(1) & _
" Is not available until " & dteStart - 1
DoCmd.CancelEvent
Exit Function
End If
If (dteStart > dteRequest1) And ((dteEnd < dteRequest) And
(dteRequest > dteStart)) Then
MsgBox "Date Range Already Booked " & _
vbCrLf & dteStart & " Thru " & dteEnd
DoCmd.CancelEvent
Exit Function
End If
End With
rs.MoveNext
Loop
End Function
Thanks in advance
Lorenzo