Results 1 to 8 of 8
  1. #1
    shralpy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    7

    Date coding

    I am relatively new to access and am trying to make the value date of form box(A) = form box (B) plus 2 years. If anyone could tell me how to do this it would be much appreciated!!!

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    In your text box B, use the DateAdd function. Here is an explanation

    http://www.techonthenet.com/access/f...te/dateadd.php

    Alan

  3. #3
    shralpy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    7
    THANKS I'm still not sure how to code dateadd ("yyyy",2, then text boxA for date

  4. #4
    shralpy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    7
    it will only except a preselected date which doesnt help me

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Put this code in an afterupdate event for textbox A.
    Code:
    Private Sub TextboxA_AfterUpdate()
    Me.textboxB.Value = DateAdd("yyyy", 2, [textboxA])
    Me.Requery
    End Sub
    Alan

  6. #6
    shralpy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    7

    code

    Thanks Alan. the textboxa is labeled Last PWRC and textboxb is labeled Next PWRC.

    do I just replace textboxA with exactly Last PWRC in the code?

  7. #7
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Yes, but as a general rule of thumb, you should not have spaces in your field names. But since you do, make sure that your surround your field name with brackets in the code. In the code title. Make sure the field name is joined with an underscore. ie. Last_PWRC. Really is best to not have spaces.

  8. #8
    shralpy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    7

    code

    Hmmm

    this is what I have:



    Private Sub LastPWRC_AfterUpdate()
    Me.NextPWRC.Value = DateAdd("yyyy", 2, LastPWRC)
    Me.Requery
    End Sub


    After i ebter the date and press tab. nothing shows up in NextPWRC

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

Similar Threads

  1. Complex Coding --> Please Help
    By JFo in forum Programming
    Replies: 231
    Last Post: 11-03-2011, 01:20 AM
  2. Coding question
    By kzoli62 in forum Access
    Replies: 1
    Last Post: 07-04-2011, 05:09 PM
  3. Combo Box Coding
    By Hale in forum Forms
    Replies: 2
    Last Post: 05-04-2010, 10:56 AM
  4. VB coding to show current date n time in access form
    By cwwaicw311 in forum Programming
    Replies: 6
    Last Post: 02-10-2010, 09:53 PM
  5. Bar-Coding
    By texasprincess7 in forum Access
    Replies: 1
    Last Post: 02-12-2009, 10:29 AM

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