Results 1 to 6 of 6
  1. #1
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125

    VBA enabling to add the Current Year in in a field.

    I have this VBA in my DB and i wish that the current year be added to it but only the last two digits of the year:

    Private Sub SupplierID_AfterUpdate()
    Me.PurchaseIDNew = "PU00" & [PurchaseIDAutoNumber]


    End Sub

    Let it look like this:

    Private Sub SupplierID_AfterUpdate()
    Me.PurchaseIDNew = "PU00" & [PurchaseIDAutoNumber] & "/" & "Current year"
    End Sub


    An example is this: PU0064/13

    Thanks in advance for your help

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Try:

    Me.PurchaseIDNew = "PU00" & [PurchaseIDAutoNumber] & "/" & Right(Year(Date()), 2)

    or

    Me.PurchaseIDNew = "PU00" & [PurchaseIDAutoNumber] & "/" & Format(Date(),"YY")
    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
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    Thanks June7 Access has automatically changed them to:

    Me.PurchaseIDNew = "PU00" & [PurchaseIDAutoNumber] & "/" & Right(Year(Date), 2)

    and

    Me.PurchaseIDNew = "PU00" & [PurchaseIDAutoNumber] & "/" & Format(Date, "YY")

    But they work perfectly

  4. #4
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    How do i mark a Thread as solve?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Thread Tools dropdown above first post.
    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.

  6. #6
    Demerit's Avatar
    Demerit is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    125
    Thanks i have seen it

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

Similar Threads

  1. Replies: 4
    Last Post: 06-30-2013, 11:20 AM
  2. checking if current year
    By snoopy in forum Queries
    Replies: 2
    Last Post: 06-20-2012, 01:46 AM
  3. Current Month and Year-To-Date
    By DSnipeFunk in forum Access
    Replies: 4
    Last Post: 05-31-2011, 11:38 AM
  4. Filet Records by Current Year
    By jbarrum in forum Access
    Replies: 6
    Last Post: 11-19-2009, 11:34 AM
  5. Changing a date to the current year
    By fdnyfish in forum Access
    Replies: 1
    Last Post: 03-01-2008, 08:34 AM

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