Default to 01/01/ of this year

B

Bonnie A

Hello everyone!!! Using A02 on XP. I have a little form I use to input date
criteria for queries, forms and reports and I would LOVE to have the begin
date default to 01/01 of the current year. 90% of the time the begin date is
Jan 01. Tried to play with it in the Default Value in properties of the
field [BeginDate]. Can anyone help?

Thanks in advance for any help or advice.
 
M

Marshall Barton

Bonnie said:
Hello everyone!!! Using A02 on XP. I have a little form I use to input date
criteria for queries, forms and reports and I would LOVE to have the begin
date default to 01/01 of the current year. 90% of the time the begin date is
Jan 01. Tried to play with it in the Default Value in properties of the
field [BeginDate]. Can anyone help?


The expression to calculate the first of the current year
is: DateSerial(Year(Date(), 1, 1)

However, (presuming that the date text box is unbound) the
DefaultValue property is only really effective when you
create a new record and the text box is bound to a field in
the form's record source table/query.

You can set the text box's value at any appropriate point in
your form, maybe in the form's Load event or after you run
the query or ???
 
B

Bonnie A

Van, you are DA BOMB!!! That was absolutely phenomenal. No way would I have
even thought to research DateSerial. THANKS BUNCHES!!!
--
Bonnie W. Anderson
Cincinnati, OH


Van T. Dinh said:
DateSerial(Year(Date()), 1, 1)

should give you the Jan 1 of the current year.

--
HTH
Van T. Dinh
MVP (Access)



Bonnie A said:
Hello everyone!!! Using A02 on XP. I have a little form I use to input
date
criteria for queries, forms and reports and I would LOVE to have the begin
date default to 01/01 of the current year. 90% of the time the begin date
is
Jan 01. Tried to play with it in the Default Value in properties of the
field [BeginDate]. Can anyone help?

Thanks in advance for any help or advice.
 
B

Bonnie A

Hi Marsh!

Thanks for the information and explanation. I always appreciate replies
from you. My form is just a parameter inquiry that has this:
=[Forms]![fCriteriaFromTo]![BeginDate] And
<([Forms]![fCriteriaFromTo]![EndDate]+1) in the criteria line of the date
field. My report has the OnOpen and OnClose event opening and closing the
fCriteriaFromTo form. Most folks are looking for YTD info and almost always
want Jan 01 of the current year in the [BeginDate] field. When the form
opens, bam!, there's 01/01/2006. I'll be able to use this one in lots of
places to save keystrokes.

How is the windy city? Got the hawk coming in off the water yet? (Got it
right this time, didn't I? Not sure now where I got 'down under' from
before.) Take care and thanks very much for your help.
--
Bonnie W. Anderson
Cincinnati, OH


Marshall Barton said:
Bonnie said:
Hello everyone!!! Using A02 on XP. I have a little form I use to input date
criteria for queries, forms and reports and I would LOVE to have the begin
date default to 01/01 of the current year. 90% of the time the begin date is
Jan 01. Tried to play with it in the Default Value in properties of the
field [BeginDate]. Can anyone help?


The expression to calculate the first of the current year
is: DateSerial(Year(Date(), 1, 1)

However, (presuming that the date text box is unbound) the
DefaultValue property is only really effective when you
create a new record and the text box is bound to a field in
the form's record source table/query.

You can set the text box's value at any appropriate point in
your form, maybe in the form's Load event or after you run
the query or ???
 

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