How to display only date as year (yyyy) in txtbox?

  • Thread starter Thread starter sebastico
  • Start date Start date
S

sebastico

Hello
Access 2003.

I have this code which works well. However, I would like to display only
year (yyyy) in textStart rather than day/month/year. Could you help me how
to do it?

txtStart Default Value : Date()

Private Sub bAddYear_Click()
Select Case Me.fraOptions.Value
Case Is = 1
Me.txtStart.Value = DateAdd("yyyy", 1, [txtStart])
Case Is = 2
Me.txtStart.Value = DateAdd("yyyy", 5, [txtStart])
Case Is = 3
Me.txtStart.Value = DateAdd("yyyy", 10, [txtStart])
End Select

Thanks in advance
 
sebastico said:
Hello
Access 2003.

I have this code which works well. However, I would like to display only
year (yyyy) in textStart rather than day/month/year. Could you help me
how
to do it?

txtStart Default Value : Date()

Private Sub bAddYear_Click()
Select Case Me.fraOptions.Value
Case Is = 1
Me.txtStart.Value = DateAdd("yyyy", 1, [txtStart])
Case Is = 2
Me.txtStart.Value = DateAdd("yyyy", 5, [txtStart])
Case Is = 3
Me.txtStart.Value = DateAdd("yyyy", 10, [txtStart])
End Select

Thanks in advance


If you set the Format property of txtStart to "yyyy" (without the quotes),
the text box will just display the year. Note that the *value* of the text
box will still be a complete date; it's just the way it is displayed that
will be different. And if the user edits the text box, it is the date
value, not just the year, that will be displayed and edited.

If what you really want is just to put a year in the text box, then you need
to set and increment its value differently.
 
Back
Top