Results 1 to 6 of 6
  1. #1
    stardog is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    6

    Calculation to automatically populate a date field

    Using Access 2010



    I think this is possible in Access, but since I have no idea how to write the calculation I am throwing this out to the experts for feedback. It involves automatically populating a future date in a form field. Here is the situation:


    I have two date fields on my form that are contextually related. One is named DateRcvdinADR and the other namedActionDeadlineDate. Regarding the ActionDeadlineDate field, is there a calculation I can enter under the Control Source for this field that will automatically insert the date for a period 30 days ahead from whatever date is entered in the DateRcvdinADRfield? As it stands now the user simply enters a date in the DateRcvdinADR field, then looks at a calendar to find the date that would be 30 days ahead, then enters that future date in the ActionDeadlineDate field. Obviously there is no problem doing it this way, but to save a step is there a way that Access can make the calculation on its own and then automatically populate the ActionDeadlineDate field accordingly?

    I am fairly well versed in Access, but I don't have a lot of experience writing complicated calculations. So if anyone has an answer please lay it out in simple terms. I am reasonably intelligent and intuitive person, but I ain't got no Phd in Advanced Access.

    Thanks for anyone's input.



    Thanks for anyone's input.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Use the DateAdd() function in the after update event of the first date textbox.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,616
    It is not necessary to save the calc into table. Calc can be done when needed in query or form textbox. Saving the calc result requires code (macro or VBA) in some event procedure, such as AfterUpdate as suggested by Paul.

    Day is default unit in arithmetic with dates so DateAdd() is not absolutely needed.

    Me!ActionDeadlineDate = Me!DateRecdInADR + 30
    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.

  4. #4
    stardog is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    6
    Thanks for the reply, but still not sure how to state the calculation, or in which field date text box it should be written. I've attached the design view of the form and date fields to give everyone a better visual of what I am trying to do. Thanks again. Sorry for my confusion on this.
    Attached Files Attached Files

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,616
    Don't save the calc into table and the issue of how to code it is eliminated.

    Do the calc in query Field row to construct a field.

    Or do the calc in textbox ControlSource property.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 06-17-2015, 09:08 PM
  2. Automatically populate expiration date
    By Tyler in forum Access
    Replies: 2
    Last Post: 01-10-2014, 10:05 AM
  3. Replies: 21
    Last Post: 08-29-2013, 11:08 AM
  4. Field content based on date calculation
    By jlmnjem in forum Programming
    Replies: 6
    Last Post: 09-23-2010, 10:24 AM
  5. Replies: 1
    Last Post: 01-30-2010, 04:45 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