[RESOLVED] Calendar control active day
Hi.... I'm using a calendar control and, if I click on an incorrect date, I want to put the focus back onto the date that was active before I clicked on the incorrect date. And I thought this would work...
Code:
calendarnumber = 1
mycalendar.value = calendarnumber
But it doesn't. So any help would be appreciated (I know about the monthview control but I just want to stick with this type of calendar for now).
Re: Calendar control active day
What, in the context of what you're trying to do, is an 'incorrect date'?
Re: Calendar control active day
Doesn't matter. MSCAL.OCX is part of Office and you can't redistribute it. It also isn't approved for use in VB6, VFP6, etc. programs much like the MS Forms 2.0 library.
Re: Calendar control active day
try something like this
Code:
Dim PreDay As Date
Private Sub Form_Load()
PreDay = 12
Calendar1.Day = PreDay
End Sub
Private Sub Calendar1_Click()
Calendar1.Day = PreDay
End Sub
Re: Calendar control active day
seenu_1st, I tried your code and it helped, thanks.
Doogle, an incorrect date is a date that isn't within a particular range. In my program the range is from the first day of the current month up to and including the current day of the current month.
I forgot to mention in my first post that I'm only trying to work with the current month's dates (my bad.) So really my question is, how do I put the focus back onto the previously active date in the current month, after I click on an incorrect date that is outside my range?
Re: Calendar control active day
After taking a break from this problem, I've decided to give it another go. So, does anyone out there have any suggestions? Thanks.
Re: Calendar control active day
Got it. The problem was that I was storing the previously active day not the previously active date. So instead of using this....
Code:
calendarnumber = format(mycalendar.value, "d")
I simply should have been using....
Code:
calendarnumber = mycalendar.value
Problem solved.