PC Review


Reply
Thread Tools Rate Thread

Correct test for an empty date?

 
 
LAS
Guest
Posts: n/a
 
      27th Aug 2010
I have a global variable that contains the last date the user entered in any
option. It should be initialized to the current date. In various forms I
need to see if it is empty so I know whether or not to assign Date(). It
looks like I need to test to see if it equals #12/4/1899#. I can do that
but it feels klugey. Is there a better way?

TIA
LAS


 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      27th Aug 2010
On Thu, 26 Aug 2010 21:12:53 -0400, "LAS" <(E-Mail Removed)> wrote:

>I have a global variable that contains the last date the user entered in any
>option. It should be initialized to the current date. In various forms I
>need to see if it is empty so I know whether or not to assign Date(). It
>looks like I need to test to see if it equals #12/4/1899#. I can do that
>but it feels klugey. Is there a better way?
>
>TIA
>LAS
>


How is it "initialized"? Unless it has a Default Value, it should be NULL (not
equal to any date). The zero point of date/time fields is #12/30/1899# - are
you doing some kind of calculation to subtract 25 days from the entered date?

Please post your code.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
LAS
Guest
Posts: n/a
 
      27th Aug 2010
I was just about to post an "oops." The value it has at the beginning is
12:00:00 AM. (I should have named the variable gdtSession_Date...)

The only place it gets established before a form is opened is in this
declaraition. When any form is opened, it has the value 12:00:00 AM.

Public gsSession_Date As Date

I used UcoraFindandReplace to be sure that it wasn't getting assigned to
anything anywhere.


"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:(E-Mail Removed)...
> On Thu, 26 Aug 2010 21:12:53 -0400, "LAS" <(E-Mail Removed)> wrote:
>
>>I have a global variable that contains the last date the user entered in
>>any
>>option. It should be initialized to the current date. In various forms I
>>need to see if it is empty so I know whether or not to assign Date(). It
>>looks like I need to test to see if it equals #12/4/1899#. I can do that
>>but it feels klugey. Is there a better way?
>>
>>TIA
>>LAS
>>

>
> How is it "initialized"? Unless it has a Default Value, it should be NULL
> (not
> equal to any date). The zero point of date/time fields is #12/30/1899# -
> are
> you doing some kind of calculation to subtract 25 days from the entered
> date?
>
> Please post your code.
> --
>
> John W. Vinson [MVP]
> Microsoft's replacements for these newsgroups:
> http://social.msdn.microsoft.com/For...-US/accessdev/
> http://social.answers.microsoft.com/.../en-US/addbuz/
> and see also http://www.utteraccess.com



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      27th Aug 2010
On Thu, 26 Aug 2010 21:37:40 -0400, "LAS" <(E-Mail Removed)> wrote:

>I was just about to post an "oops." The value it has at the beginning is
>12:00:00 AM. (I should have named the variable gdtSession_Date...)
>
>The only place it gets established before a form is opened is in this
>declaraition. When any form is opened, it has the value 12:00:00 AM.
>
>Public gsSession_Date As Date
>
>I used UcoraFindandReplace to be sure that it wasn't getting assigned to
>anything anywhere.


Sorry... it's a VBA variable, not a table field! My answer applied to the
latter.

If you use As Date in the Dim, then the variable must indeed have a value;
it's defaulting to 0.0, which is equivalent to #12/30/1899 00:00:00# and will
indeed be displayed as 12:00:00 AM.

You can test for it being uninitialized by comparing it to #12/30/1899# or to
#12:00:00 AM# or to 0, all of which are just different ways of depicting the
same thing... but it can't be NULL, as a table field can.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
David W. Fenton
Guest
Posts: n/a
 
      27th Aug 2010
"LAS" <(E-Mail Removed)> wrote in
news:i573el$69v$(E-Mail Removed):

> I have a global variable that contains the last date the user
> entered in any option. It should be initialized to the current
> date. In various forms I need to see if it is empty so I know
> whether or not to assign Date(). It looks like I need to test to
> see if it equals #12/4/1899#. I can do that but it feels klugey.
> Is there a better way?


Don't use globals.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need urgent help selecting correct test!! Pizza Microsoft Excel Worksheet Functions 0 13th Feb 2009 03:16 PM
How do I correct a Logical Test error in Excel eye-for-detail Microsoft Excel Crashes 2 12th Mar 2008 02:59 AM
How to put test questions then student answers and get % correct =?Utf-8?B?S2F0aHk=?= Microsoft Excel Worksheet Functions 2 23rd Jul 2007 03:32 PM
test for empty date mcnewsxp Microsoft Access Queries 19 25th Feb 2006 01:23 PM
Correct date preview correct but printed as #Name? =?Utf-8?B?UnVpIFNhbnRvcw==?= Microsoft Access Reports 1 16th Nov 2004 02:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 PM.