Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter Date and it automatically put Year in Seperate Field 1

Status
Not open for further replies.

useractive

Programmer
Jun 21, 2001
98
US
Is it possible to setup in a table that when the individual is going through and filling out the table and put in the date of the event, it puts the year automatically in the next field? Thanks, Swish
 
If you are entering the data through a form, you could do it this way...

[EventDate] is the field in which the user enters the event date. (for example 10/12/03)
[YearDate] is a second field that derives its value from the [EventDate] field, using =Format([EventDate],"yyyy")

You would then have a field in the main table called YearDate

The fields I have used, of course, are examples. You would have to change them to suit your own field names.

Tom
 
Sorry, I answered too quickly.

If you want to store the year back in the table...
1. Set up the table with an [EventDate] and set its format to mmm/dd/yyyy. Also a [YearDate] with a format as yyyy

2. In your input form, both the [EventDate] and [YearDate] fields will have their corresponding fields in the table as their source, and set their format to the same as it is in the table. The important one is the yyyy in the [YearDate]

3. In the AfterUpdate event of the [EventDate] put this code Me.YearDate = Me.EventDate

That should do it.

Tom
 
Not quite sure why a 'year' field is needed. The year can always be extracted from EventDate using the YEAR function in forms, reports, and queries -- YEAR([EventDate]).

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top