Results 1 to 6 of 6
  1. #1
    zen13 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    6

    Question How to use VBA codes to update table values with link to CURRENT DATE

    Dear All,

    I'm new to Access and programming, will appreciate your help.

    I was given a set of data table with Age e.g 23, 30,42 and it needs to be updated yearly.



    I found a code(shown below) , but is there a way to modify it so that the output value of "YearDiff" can be used in table or exported as field?

    ****

    Sub AgeUpdate()
    Dim TheDate As Date ' Declare variables.
    Dim Msg
    DateCreated = "2017/05/17"
    Msg = "YearDiff: " & DateDiff("yyyy", DateCreated, Now)
    MsgBox Msg
    End Sub

    ****


    Many thanks and I hope to hear from anyone soon <3

  2. #2
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Age should be a calculation from date of birth. This requires no update.

  3. #3
    zen13 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    6
    Quote Originally Posted by Homegrownandy View Post
    Age should be a calculation from date of birth. This requires no update.
    Hi there the issue is, the data imported from excel was given in actual age and not date of birth

  4. #4
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    convert them all to a date of birth? It will be equally as accurate as what you're suggesting to do and requires no update.

    in excel have a list of all the ages and do = 2017 -A1 and so on.

  5. #5
    zen13 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    6
    Quote Originally Posted by Homegrownandy View Post
    convert them all to a date of birth? It will be equally as accurate as what you're suggesting to do and requires no update.

    in excel have a list of all the ages and do = 2017 -A1 and so on.
    I will try! thank you for your input~

  6. #6
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    If you need help displaying that calculation feel free to make a new thread.

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

Similar Threads

  1. Update table based on Max date link
    By janmack79 in forum Queries
    Replies: 2
    Last Post: 04-11-2017, 12:46 PM
  2. Replies: 6
    Last Post: 04-16-2016, 10:18 AM
  3. Replies: 3
    Last Post: 08-21-2015, 08:14 AM
  4. After Update / Populate current date
    By Eric2013 in forum Forms
    Replies: 3
    Last Post: 01-29-2015, 08:33 PM
  5. Check dosent update current date
    By bsunuwar in forum Access
    Replies: 10
    Last Post: 03-23-2011, 09:46 PM

Tags for this Thread

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