Fill a 'year' field from a 'date' field

WinDancer

Registered User.
Local time
Today, 01:45
Joined
Oct 29, 2004
Messages
290
I need to fill a year field on a form from a date field on the same form when the date field is filled in by the user.
Thanks,
Dave
 
You wouldn't want to save it, but you can get the year of the date with the Year() function.
 
You could always try the split function. Here is an example of a field which has a date entered and then split to give the month and the year into other firelds. This also assumes an Australian Date dd/mm/yyy with the "/" as the seperator. This is a powerful inbuilt function and can be used for a multitude of uses.

If Not IsNull(Me!EnteryDate) Then
'MsgBox (Split(Me!EnteryDate, "/")(1) & vbCrLf & Split(Me!EnteryDate, "/")(2))
Me!month = Split(Me!EnteryDate, "/")(1)
Me!Year = Split(Me!EnteryDate, "/")(2)
End If

I hope this helps.
 
Split() is a useful function, but Year(DateField), Month(DateField) and Day(DateField) is about as simple as it gets, and you're not limited by the date format that's in use.
 
missinglinq, thank you! again. I used your code again today. It is exactly what I was looking for.
Dave
 

Users who are viewing this thread

Back
Top Bottom