Back to the...past?

George Too

Registered User.
Local time
Today, 06:38
Joined
Aug 12, 2002
Messages
198
Hi all,
Can anyone tell me why this line of code gives me 12/30/99 and not today's date?

Forms!frmMain!txtAnalysisDate.DefaultValue = Format(Now(), "mm/dd/yy")

Thanks,
George
 
What date is your computer date?
(Start with the obvious first;) )
Dave
 
Try a different aproach
Forms!frmMain!txtAnalysisDate.DefaultValue = Format(Date(), "mm/dd/yy")
The Now() function includes the time and date. Works well in excel but is unreliable in access
HTH
Dave
 
Thanks Oldsoftboss, but doesn't work. For some reason the parentheses after Date are removed by the compiler after I finish typing the line and the date keeps on being 12/30/99. My pc's date is up to date. Any other ideas?

George
 
The parentheses after Date aren't required in vba and are therefore removed automatically, why not just put =Date() in the default value on the property sheet. What are your regional settings set to?
 
My regional settings are correct (GMT -5 eastern US).
My tables don't have a default value (default value is empty), and the reason I don't use "=Date()" in the default value field is because I use the form for two purposes, one is to get data and the other just to display data.
When the user is entering the data, I want Access to supply the current date, but when it's in info mode, Access gets the date from the tables. Using the default value in the properties of the form does give me the right date though.

Any other ideas?

Thanks,
George
 
Sorry I don't understand your definition, If users can use the form to both view and add records having the default value set to =Date() will not affect existing records, what's your reason for not using this method?
 
Rich, I have no problem regarding existing records, all I want is a blank field when the form is open in view only, and the actual date when the form is open in data entry. That's why I wanted to do it through code.
Now, regarding Pat's contention, I haven't given it a format. There isn't an input mask in the field either. All i'm doing is executing this line of code
Forms!frmMain!txtAnalysisDate.DefaultValue = Date

Thanks for your replies guys,
George
 
Pat is recommending that you change the display format to the four year display mm/dd/yyyy, that will prove/disprove that the Date is 1899
 
I have tried the format route left and right but I still don't get the desired output, in this case 1899. What I've been getting is this number 5.34911917837529E-05 which complicates things even more.

Thanks for your help guys,

George
 

Users who are viewing this thread

Back
Top Bottom