Something odd with the Calendar control

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

Hi there,
Maybe I should post this item elsewhere but perhaps
you've come across this yourselves and can explain what's
happening. I've got the MSCAL.Calendar.7 control in a
form and have set it to Now() when the form is loaded.
The date that appears in a text box (that gets its value
from the Calendar) shows todays date but tomorrows date
is actually highlighted on the Calendar Control.....very
odd! If I do 'Now()-1' then yesterdays date is shown in
the text box but today is highlighted on the Calendar.
Can anyone explain what's happening here?

Kind regards

Lee
 
Now() is the wrong function to use - it returns both the current date and the
current time. Put this expression in te OnOpen event of your calendar form:

Me!NameOfCalendarControl.Value = Date()
 
Thanks for the reply.
I'm not sure why be this doesn't work on the On Open
event but it does on the On Load one so all is well!
Kind Regards,
Lee
 
Thanks for the reply.
I'm not sure why be this doesn't work on the On Open
event but it does on the On Load one so all is well!
Kind Regards,
Lee

If the calendar is bound, then you can't use the on-open. In fact, you can't
modify ANY bound field, text box, etc. On-open is NOT the place where you
should be setting the forms defaults, and running setup code. That code
belongs in the on-load, where you CAN modify the fields.

The on-open event does have a cancel option. So, often, when certain
conditions are met (or not met), then you can cancel the form open. Thus,
on-open is for testing and cancelling the form if some type of condition is
not meet.

on-open (test for ondistios code, can prevent form load)
on-load setup default vales, run setup code
 
Back
Top