Results 1 to 7 of 7
  1. #1
    quinnsfpa is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2015
    Posts
    5

    DateAdd not working


    Hi, I'm new to this forum and, after tearing my hair out for the last day, am hoping someone can help me. I have a form which contains 2 date fields (DateReg and Deadline). I need the deadline date to automatically populate - 30 days after Date Reg

    So far, I have tried to create an event for Deadline (On Click) and an event on DateReg (After Update), neither of which have worked. I have googled like crazy and tried several variations of code but none of them have worked.

    The other thing I have tried is to just enter the code directly into the table (Default Value).

    Can someone please tell me the code I should be using?

    Thank you.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,649
    There really is no need to save the Deadline calculated value. This actually violates common relational database wisdom. Calculate the value when needed.

    Show the code you have attempted. Could simply be:

    Me!Deadline = Me.DateReg + 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.

  3. #3
    quinnsfpa is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2015
    Posts
    5
    Thank you for your very prompt reply June I'm afraid this is still quite new to me and I'm learning a lot as I go along. Two of the codes I attempted were DateAdd("d",30,date()) and DateAdd("d",30,[DateReg]). I'll try the code you've given me - Me!Deadline = Me.DateReg + 30 - but am unsure where to enter this code?



    Quote Originally Posted by June7 View Post
    There really is no need to save the Deadline calculated value. This actually violates common relational database wisdom. Calculate the value when needed.

    Show the code you have attempted. Could simply be:

    Me!Deadline = Me.DateReg + 30

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,649
    You can use it in a query to construct a field or in textbox on form or report. Creating fields with expression in query is basic Access functionality. http://www.gcflearnfree.org/access2013/19
    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.

  5. #5
    quinnsfpa is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2015
    Posts
    5
    Thank you. I'd already tried entering the code directly into a text box but when I view the report I see #Name?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,649
    The equation I provided would be used in VBA procedure to save the calculated value.

    Otherwise, use expression in textbox ControlSource. This will display the value but not save to table.

    = DateAdd("d",30,[DateReg]).
    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.

  7. #7
    quinnsfpa is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2015
    Posts
    5
    Thank you That's the code I was already using but I was trying to add it to the Deadline field. Now that I've entered it into a text box it's worked. Thank you! I can't believe it was something so simple as entering it into a text box instead of the actual field!

    I've never used VBA but would certainly like to learn so I think I'll look into it. Thank you for your help - much appreciated.


    Quote Originally Posted by June7 View Post
    The equation I provided would be used in VBA procedure to save the calculated value.

    Otherwise, use expression in textbox ControlSource. This will display the value but not save to table.

    = DateAdd("d",30,[DateReg]).

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

Similar Threads

  1. Replies: 3
    Last Post: 06-26-2015, 09:40 AM
  2. the DateAdd
    By azhar2006 in forum Queries
    Replies: 1
    Last Post: 04-20-2014, 03:18 PM
  3. DateAdd Error
    By TimMoffy in forum Programming
    Replies: 2
    Last Post: 04-17-2013, 10:13 AM
  4. DateAdd()
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 11-22-2011, 02:20 PM
  5. dateadd help
    By dubsdj in forum Queries
    Replies: 3
    Last Post: 03-03-2011, 07:22 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