PRB: OLE Error with Empty or NULL ControlSource with Date and Time Picker (253588)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q253588 SYMPTOMS
When a Date and Time Picker ActiveX control is added to a form, its ControlSource set to a date field, and the record pointer moved to a record that contains a blank value in the date field, the following error message appears:
OLE IDispatch exception code 0 from DTPicker: A date was specified that does not fall within the MinDate and MaxDate Properties...
When the record pointer is moved to a record that contains a NULL value in the date field, the following error message appears:
OLE IDispatch exception code 0 from DTPicker: Invalid Property Value. CAUSE
The DateTimePicker control's Calendar interface handles adjusting the Day, Month, and Year properties to create a valid date. If a value is assigned that creates an invalid date, one of the error messages above appears. This behavior occurs because the DateTimePicker control does not recognize {" / / "} as a valid date. Likewise, the DateTimePicker control does not recognize a NULL as a valid date.
RESOLUTION
Use the EMPTY() or ISNULL() functions to determine whether the date field that is the ControlSource for the DateTimePicker control is blank or NULL. If the field contains a blank or NULL value, set the ControlSource property of the DateTimePicker control to a NULL string. If the field is not blank, set the ControlSource of the DateTimePicker control to the datefield.
IF !EMPTY(TESTDTP.DTP_DATEA)
THISFORM.DTPicker1.CONTROLSOURCE="TESTDTP.DTP_Datea"
ELSE
THISFORM.DTPicker1.CONTROLSOURCE=""
ENDIF
IF !ISNULL(TESTDTP.DTP_DATEB)
THISFORM.DTPicker2.CONTROLSOURCE="TESTDTP.DTP_Dateb"
ELSE
THISFORM.DTPicker2.CONTROLSOURCE=""
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: | kbContainer kbCtrl kbDSupport kbprb KB253588 |
---|
|