Results 1 to 4 of 4
  1. #1
    jamril is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    2

    On button press should update the year

    Dear all,

    I just confuse for VBA code, that is, in Access form text box contain year, nearby i put on button named update, so when I press the button year should be increase to next year.. ex Text box data is 01/01/2012, so when i will press the button text box data should be changed to 01/01/2013,,

    I tried some codes but I failed



    Plz can any one help in these code??

    Thanks in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Are you changing date value for existing records? Why would you do that?

    Use DateAdd function to add a year. Show your attempted code.

    Beware user error. If user accidentally repeatedly presses button, the date will be repeatedly incremented. And what if user forgets to press button when they should?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    This worked for me.
    Code:
    Private Sub Command2_Click()
    Dim dTxt As Date
    
    
    dTxt = DateAdd("yyyy", 1, Text0)
    Me.Text0.Value = dTxt
    Me.Requery
    
    
    End Sub
    Edit: All good points made by June if you go down this road.

  4. #4
    jamril is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    2
    Thankyou alansidman,,,,,,, your formula is working fine,, Thankyou once again.....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-09-2013, 09:23 PM
  2. Replies: 3
    Last Post: 11-25-2012, 06:09 PM
  3. Press a button to combine two fields to open a PDF
    By Douglas Post in forum Programming
    Replies: 4
    Last Post: 02-11-2012, 02:02 PM
  4. Replies: 0
    Last Post: 11-22-2011, 09:10 PM
  5. Replies: 0
    Last Post: 07-05-2011, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums