ACC: Calendar Control Adds One Day When Time Is After 12:00 PMID: Q169599
|
Moderate: Requires basic macro, coding, and interoperability skills.
When a Calendar Control is assigned a value that includes the time as well
as the date, it displays a date one day greater than the value if the time
is after 12:00 P.M.
You are using either the version of the Calendar Control that ships with Microsoft Access 97 or the version that ships with the Microsoft Access Developer's Toolkit 2.0, and the control is rounding the value that has been assigned to it. In a date serial number, the time portion is stored to the right of the decimal point. Therefore, the Calendar Control will round the date up if the time is after 12:00 P.M. As a result, it displays a date one day greater than the date of the value assigned to it.
Because the DateValue() function doesn't recognize time information, you
can apply DateValue() to the value that you have assigned to the Calendar
Control. For example, if you assign the value in a text box named
CalendarDate to a Calendar Control named Calendar1, you can use the
following line of code:
Me!Calendar1.Value = DateValue(Me!CalendarDate)
This behavior does not occur with the version of the Calendar Control that ships with Microsoft Access for Windows 95 version 7.0.
Private Sub CalendarDate_AfterUpdate()
Me!Calendar1.Value = Me!CalendarDate
End Sub
Sub CalendarDate_AfterUpdate ()
Me!Calendar1.Object.Value = Me!CalendarDate
End Sub
For more information about the DateValue() function, search the Help Index for "DateValue."
Keywords : kbusage
Version : 2.0 97
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 22, 1999