From: Sanjay Kulkarni on 23 Mar 2010 03:48 Hi, Thanks all for the responses. Finally I changed the constant declaration to Const ChkDate As Date = #3/10/2010# and the code to If Now() > ChkDate then msgbox "Send Reminder" End If And it worked. But mystery remains about the exact cause of error. Why previous code did work on 2 PCs and not on the third PC even when all the date settings were changed in accordance with the third PC.
From: Mike Williams on 23 Mar 2010 05:12 On 23 Mar, 07:48, Sanjay Kulkarni <sanganaksa...(a)gmail.com> wrote: > Finally I changed the constant declaration to > Const ChkDate As Date = #3/10/2010# > and the code to > If Now() > ChkDate then I assume you're aware that the above code will return True as soon as Now() reaches the specified date (on the very first second of 10th March 2010 in the example) as well as when it is greater than it, because Now() contains the time whereas #3/10/2010# does not. It's not a problem of course because if that is not what you want then you can amend your code to account for it, but I just thought I'd mention it in case you didn't know. > But mystery remains about the exact cause of error. > Why previous code did work on 2 PCs and not on the > third PC even when all the date settings were changed > in accordance with the third PC. Perhaps you missed one. I'm not sure whether all versions of Windows behave in the same way but it is possible, for example, to change the "location" without changing the date format. I would say the error almost definitely occurred because "March" was not a valid month name on the target machine. It's probably as well anyway that you did get a failure on one machine because it gave you the opportunity to change your code so that it is not affected by different locales. I still don't like that #3/10/2010# though. That strange and illogical ordering of the date parts still gets right up my nose, and ordinary people reading such a date would immediately assume it mean 3rd October 2010 in many parts of the world. Personally I prefer to use the more sensible DateSerial function, which is also "locale proof" but which has the date parts in a logical order :-) Mike
From: Sanjay Kulkarni on 24 Mar 2010 12:20 On Mar 23, 2:12 pm, Mike Williams <gagam...(a)yahoo.co.uk> wrote: > On 23 Mar, 07:48, Sanjay Kulkarni <sanganaksa...(a)gmail.com> wrote: > > > Finally I changed the constant declaration to > > Const ChkDate As Date = #3/10/2010# > > and the code to > > If Now() > ChkDate then > > I assume you're aware that the above code will return True as soon as > Now() reaches the specified date (on the very first second of 10th > March 2010 in the example) as well as when it is greater than it, > because Now() contains the time whereas #3/10/2010# does not. It's not > a problem of course because if that is not what you want then you can > amend your code to account for it, but I just thought I'd mention it > in case you didn't know. > > > But mystery remains about the exact cause of error. > > Why previous code did work on 2 PCs and not on the > > third PC even when all the date settings were changed > > in accordance with the third PC. > > Perhaps you missed one. I'm not sure whether all versions of Windows > behave in the same way but it is possible, for example, to change the > "location" without changing the date format. I would say the error > almost definitely occurred because "March" was not a valid month name > on thetargetmachine. It's probably as well anyway that you did get a > failure on one machine because it gave you the opportunity to change > your code so that it is not affected by different locales. > > I still don't like that #3/10/2010# though. That strange and illogical > ordering of the date parts still gets right up my nose, and ordinary > people reading such a date would immediately assume it mean 3rd > October 2010 in many parts of the world. Personally I prefer to use > the more sensible DateSerial function, which is also "locale proof" > but which has the date parts in a logical order :-) > > Mike Thanks Mike, I'll explore the DateSerial function and use it. - Sanjay Kulkarni
First
|
Prev
|
Pages: 1 2 3 Prev: Working with non-MS software in Vis Studio Next: Slow response to label.click event |