PRB: Error When Setting DateTimePicker Control Programmatically (253785)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q253785 SYMPTOMS
When attempting to set the date of a DateTimePicker control programmatically, the following error message might appear:
OLE IDispatch exception code 0 from DTPicker: Invalid Property Value.
CAUSE
When using the DateTimePicker control's Calendar interface to change the date, the control handles adjusting the Day, Month, and Year properties to create a valid date. If a value is assigned that creates an invalid date, the error message above is displayed.
RESOLUTION
Use the GOMONTH() function to return a valid date, which can then be used to set the Day, Month, and Year properties of the DateTimePicker control as follows:
olddate=exampledate
exampledate=exampledate+(number_of_days_to_change)
IF MONTH(exampledate)<>MONTH(olddate)
olddate=GOMONTH(olddate,-1)
THISFORM.DTPicker1.DAY=DAY(olddate)
THISFORM.DTPicker1.MONTH=MONTH(olddate)
THISFORM.DTPicker1.YEAR=YEAR(olddate)
ENDIF
STATUS
This behavior is by design.
REFERENCESFor additional information DTPicker ActiveX Control, click the article number below
to view the article in the Microsoft Knowledge Base:
189991 PRB: Error Setting DateTimePicker's Month Programmatically
Modification Type: | Major | Last Reviewed: | 8/27/2002 |
---|
Keywords: | kbCtrl kbDSupport kbprb KB253785 |
---|
|