Lebans Calendar Control questions

G

Guest

I'm using this Calendar control now (was using Active X calendar control).

Im setting dates in a listbox control which contains many dates.

I have 2 problems:

(1) I need to validate the date (sometimes it cannot be in the future) and
would like the window to stay open while I do it so the user can immediately
choose another date. Any way to do ?

(2) Sometimes I need to select the same date multiple times, is there any
way to get the calendar to display with the last selected date automatically
selected again?

Thse things were easy the activex control approach.
 
J

Jeff Conrad

in message:

Comments below.....
I'm using this Calendar control now (was using Active X calendar control).

Im setting dates in a listbox control which contains many dates.

I have 2 problems:

(1) I need to validate the date (sometimes it cannot be in the future) and
would like the window to stay open while I do it so the user can immediately
choose another date. Any way to do ?

I do not believe this is possible, but knowing Stephen he will come along
and prove me wrong.
:)

I always let the user select any date they want and then do my testing
when it is needed.
(2) Sometimes I need to select the same date multiple times, is there any
way to get the calendar to display with the last selected date automatically
selected again?

In my opinion this might be sometimes counter-productive, but I do
see your point.

Some quick testing with three date field text boxes and I believe
this code below appears to do what you want.

Declare a private date variable in the Declarations area of the form:

Private dteSelectedDate As Date

Then in the double click event for each text box I used this:

Private Sub butSetTarget_DblClick(Cancel As Integer)
On Error GoTo ErrorPoint

Dim dtStart As Date
Dim dtEnd As Date

dtStart = Nz(Me.butSetTarget.Value, 0)
dtEnd = 0

If dteSelectedDate <> #12:00:00 AM# Then
' There is a saved date present so use it
If ShowMonthCalendar(mc, dteSelectedDate, dtEnd) Then
Me.butSetTarget = dteSelectedDate
dteSelectedDate = Me.butSetTarget
End If
Else
' No value presently known
If ShowMonthCalendar(mc, dtStart, dtEnd) Then
Me.butSetTarget = dtStart
dteSelectedDate = Me.butSetTarget
End If
End If

ExitPoint:
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub

If you wanted to get real technical you could have a checkbox on the form
that toggles the use of that private variable. That way you could turn it
off when you wanted to. Just an idea.
 

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