Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DtPicker problem
Message
From
01/08/2003 06:12:01
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00815610
Message ID:
00815780
Views:
19
This message has been marked as the solution to the initial question of the thread.
>Hi all, I have a form which uses a DtPicker control to select a date, the value of the control is set to the DATE() value in the INIT event. Everything was working fine until today. When I try to set the date to 07/31/2003 I get the error message:
>
>Invalid property value
>
>
>I did a search in the Knowledge base and the file Q253785 suggest a way to solve this problem, I tried it but didn't work. The problem seems to be that the dtpicker control does not recognizes the 31th day as a valid day because when I changed the date to for example 08/31/2003 I get the same error message. This error message seems to occur only with this particular day of the month.
>
>Can anybody suggest a workaround for this problem?
>
>TIA,
>
>Enmanuel

Enmanuel,
Very helpfull KB article :) I couldn't understand the resolution a bit to be honest.

Whenever you change a day, month or year property dtpicker tries to construct a new date using those values and if result is an invalid date then the error occurs (almost a copy of what KB says:)

The workaround is simple. Do it in a way so that you never cause an invalid date :
ldDate = {^2003/07/31}

* Note: Assuming your setting would be in Mindate-Maxdate limits
* not including a check for it
with thisform.dtPicker
  ltMinDate = .MinDate && Save current min-max dates
  ltMaxDate = .MaxDate
  .MinDate = {^1601/01/01 00:00:00} && min control accepts
  .MaxDate = {^9999/12/31 00:00:00}
  
  .Year = 2000 && Known leap year - so all month/day settings are valid
  .Month = 1   && Jan has 31 days - so all days are valid
  * Now can set the day/month/year safely  in this order
  .Day = day(ldDate) 
  .Month = month(ldDate)
  .Year = year(ldDate)
  
  .MinDate = ltMinDate && Restore min-max dates of control
  .MaxDate = ltMaxDate
endwith
Did I say simple ? So it must be simple :) Another workaround then. DtPicker control uses a datetime value so I can set its value directly rather than setting day,month,year individually :
ldDate = {^2003/07/31}
thisform.dtpicker.OBJECT.value = dtot(ldDate)
Note that it's .object.value not just .value.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform