Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTPICKER Control property error

Status
Not open for further replies.

bobmpalmer

Programmer
Aug 19, 2003
161
GB
An odd thing occured in our code with the dtpicker. Dave Summers replied to a thread that I refered to when using this control to set Mindate/maxdate properties.
thread1254-824667

The control and code has existed in a release of our software for 5 months now and is being used on 30+ sites daily with no error.

The specific code lines are, as in daves post in the above thread:-
Code:
MyForm.oleDTPicker.object.MinDate = Date() - 180
MyForm.oleDTPicker.object.MaxDate = Date()
Except that our values are date()-180 and date()

Yesterday 25/03/2005 I recieved calls from clients with an Ole dispatch error saying min value was greater than max value!!!

The fix was to reverse the two lines e.g.
Code:
MyForm.oleDTPicker.object.MaxDate = Date()

MyForm.oleDTPicker.object.MinDate = Date() -180
So that the max value was set first.

In hindsight this appeared obvious except, does anyone have any idea why the original worked fine UNTIL 25/03/2005 and then produced the error()? what has changed so that on instanciating the object the two values are evaluated and create the error? One client used the module on the morning of the 25th with no error but on the afternoon when running the module the error occured.

App is written in VFP7. Any pointers suggestions would be appreciated ta!




Bob Palmer
The most common solution is H2O!
 
Can you set your clock back to the 25th and do some testing and see where it throws the exception and what is different about the values?

boyd.gif

 
Don't have to set the date back Craig the code still does it today. It is since the 25th or actually the 24th according to one client.

With the object properties as in example 1 above
MyForm.oleDTPicker.object.MINDate has a value of 01/01/1601 at the point of the ole dispatch error!! according to VFP's debug and for some really strange reason
MyForm.oleDTPicker.object.MAXDate has a value of 24/09/2004
which even though weird should still not produce an error as maxdate is still > than mindate.

I am wondering if the objects properties have some internal default value that cannot evaluate correctly. You would have expected the objects default values to be date() date() respectively or at least I would.

The actual exact error is:
OLE 1Dispatch exception code 0 from DTPicker: A value was specified for the MinDate property that is higher than the current value of MaxDate...


Bob Palmer
The most common solution is H2O!
 
OK Craig,
This was a little more complex than it seems because our system is designed to NOT let the system date be wound back so I set up a duplicate dev system with the date starting 22/03/2005

System date set on the 22/03/2005
DT Picker with mindate line first (as in my org code)

Values in Debug:-
object.mindate= 23/09/2004 (date()-180)
object.maxdate= 22/03/2005 (DATE())

Increment sys date to 23/03/2005

object.mindate= 24/09/2004 (date()-180)
object.maxdate= 23/03/2005 (DATE())

*** Both as expected and experienced by my clients with no errors.

Increment to 24/05/2005 on the system date

object.mindate= 01/01/1601 ???????
object.maxdate= 24/03/2005 (DATE())

And all dates subsequent to 24th the error occurs and mindate ALWAYS is 01/01/1601

Bob Palmer
The most common solution is H2O!
 
I just tried this with a datepicker control in a test form. I put this code in the Form's Init:

ThisForm.olecontrol1.object.MinDate = DATE()-180
ThisForm.olecontrol1.object.MaxDate = DATE()

Ran with no problems. Where do you have the code? What else have you changed about the control?

Tamar
 
The code is in a method thisform.setupform called as the last line in the forms init.

It appears that it is related to the default properties of the DTpicker.

By default they are MIN DATE 01/01/1601 MAX DATE 31/12/9999

If you alter the MAX DATE to ANY value less than today and run the code, unless you assign the MAX date in code first you will get the error!! This may seem obvious except, the MAX date AND Value values were both the same in this particular object and were set at 24/09/2004 which was the date the object was first placed on the form, the MIN date was the default 01/01/1601.
The error only started happening on 24/03/2005 which is 181 Days after the preset dates and as my code was trying to store DATE()-180!! Min date is indeed greater than max at the point of assignment. This implies that the min date has a trigger that evaluates at the time of assignment and if assigned first can cause an error!!



Bob Palmer
The most common solution is H2O!
 
The 181 day correlation makes sense. Glad you were able to figure it out. It does make sense, and I can see how a thing like that could fake a developer/tester out for about 6 months before they realized there was a problem. Thanks for getting to the bottom of it Bob.

boyd.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top