Insert Current Year in a field from a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clloyd
    New Member
    • Mar 2008
    • 91

    Insert Current Year in a field from a form

    I have a form that when you hit a command button it moves the current year value (could be three years prior) to a previous year field. I need code to insert the current year in the current year field. I know this has to be simple but I just can't get it done.
  • clloyd
    New Member
    • Mar 2008
    • 91

    #2
    Originally posted by clloyd
    I have a form that when you hit a command button it moves the current year value (could be three years prior) to a previous year field. I need code to insert the current year in the current year field. I know this has to be simple but I just can't get it done.

    I got it
    Code:
     helpfield = DatePart("yyyy", Now())

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32634

      #3
      Now() is fine, but Date() is probably the one you'd need.

      Your code returns a string. The following returns the number. If putting into a TextBox control it would matter of course.
      Code:
      helpfield = Year(Date())

      Comment

      Working...