Default Date in a control on a form

G

Guest

I have a form with 2 controls [BeginningDate] and [EndingDate] I'm trying to
set the default for BeginningDate to 01/01/2005 and the EndingDate to
12/31/2005. No matter what I do, I keep getting the date of 12/30/1899.
The controls are formatted for short date and the input mask is
99/99/0000;0;_ How do I do this??

Thanks!
 
D

Douglas J Steele

I'm assuming you're putting 01/01/2005 and 12/31/2005 as the default values.
Access sees those as calculations, so gets .00049875 for the former, and
0.000193065 for the latter. Internally, Access stores date/time values as 8
byte floating point numbers , where the integer portion represents the date
as the number of days relative to 30 Dec, 1899, and the decimal portion
represents the time as as fraction of a day. Therefore, Access thinks your
first value is 00:00:43 on 30 Dec, 1899, and the second value is 00:00:17 on
the same day.

Dates need to be delimited with # characters: #01/01/2005# and #12/31/2005#
 
J

John Vinson

I have a form with 2 controls [BeginningDate] and [EndingDate] I'm trying to
set the default for BeginningDate to 01/01/2005 and the EndingDate to
12/31/2005. No matter what I do, I keep getting the date of 12/30/1899.
The controls are formatted for short date and the input mask is
99/99/0000;0;_ How do I do this??

Thanks!

Just to add to Douglas' good suggestions, you can avoid the problem of
needing to update the default every year by using a DefaultValue
property of

=DateSerial(Year(Date()), 1, 1)

This will default to 1/1/2005 this year, 1/1/2006 starting January 1
next year and so on.

John W. Vinson[MVP]
 
G

Guest

I used the =DateSerial(Year(Date()),1,1) for the beginning date and it worked
great.

Thanks!

John Vinson said:
I have a form with 2 controls [BeginningDate] and [EndingDate] I'm trying to
set the default for BeginningDate to 01/01/2005 and the EndingDate to
12/31/2005. No matter what I do, I keep getting the date of 12/30/1899.
The controls are formatted for short date and the input mask is
99/99/0000;0;_ How do I do this??

Thanks!

Just to add to Douglas' good suggestions, you can avoid the problem of
needing to update the default every year by using a DefaultValue
property of

=DateSerial(Year(Date()), 1, 1)

This will default to 1/1/2005 this year, 1/1/2006 starting January 1
next year and so on.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top