Default value

T

Tara

I'd like to set the default value of a field to the last day of the year the
starting date is in. For example, My starting date is 04/12/2008. I'd like
the end date to default to 12/31/2008, even if the record isn't actually
created until sometime in 2009.

Thanks!
 
D

Douglas J. Steele

I don't believe there's anyway to have a dynamic default value, which is
what you appear to want.

Assuming you're using a form, though, you can achieve the desired result
using VBA.

In the AfterUpdate event of your StartDate control, use code like:

Private Sub StartDate_AfterUpdate()

Me!EndDate = DateSerial(Year(Me!StartDate), 12, 31)

End Sub
 
B

BruceM

You don't need to store the end date. When you need the EndDate, in an
unbound text box on the same form or report as the StartDate, set the
Control Source to:
=DateSerial(Year([StartDate]),12,31)

As an alternative, create a query based on the table you are using as the
record source of your form or report. At the top of an empty column:
EndDate: DateSerial(Year([StartDate]),12,31)
Bind a text box to EndDate.

In either case, use the desired date format in the text box Format property
(on the form's Property Sheet).
 

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