Stephen Lebans Calendar and event triggering

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
 
S

Stephen Lebans

Lorenzo you are calling the ShowMonthCalendar function. Why don't you
simply call your CheckDeparture Sub immediately after the call to
ShowMonthCalendar?

I do not understand your second question.
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.

You are free to modify the source code as you see fit. But there is no
method I know of that allows you to specify the background color of
dates with their DayState property set.


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Lorenzo said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top