Results 1 to 13 of 13
  1. #1
    armyofdux is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    55

    DateAdd Function

    I am trying to get the right syntax to use the DateAdd Function. Here goes

    I have a field in the tbl Student Data titled DATE_ADDED. I have an append query setup to add data to a another table (Booking).. I can't get the syntax right to make it work.

    This is what I have. I want it to append the data to matching fields in the booking table meeting the following criteria of 10 seconds after it is added.

    >DateAdd("s",10,[DATE_ADDED])



    It recognizes it as proper syntax because it doesnt error out but it doesnt do anything with respect to appending data.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    You seem to be adding 10 seconds to Date_Added -- is that what you meant to do?

  3. #3
    armyofdux is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    55
    No, I want to append data based on it being older than 10 seconds since it was created.

    Maybe more like this... but I am not getting any results. "WHERE">DateAdd("s",10,Date())

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    You will need something along the lines of

    vba:
    If ( Datediff("s", Date_added, Now()) >10 ) then
    do something

    or with immediate iif

    IIF( Datediff("s", Date_added, Now() >10 ), Truepart,Falsepart)
    Last edited by orange; 02-11-2015 at 08:45 PM.

  5. #5
    armyofdux is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    55
    I can't get the syntax to work right, is there any easy way to take data entered into a form and then press a button to copy the like fields to another table. I know I just described an append query but everytime I do it I get no results copied. It runs but it just doesnt produce.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I think orange's expression has misplaced ) :

    IIf(Datediff("s", Date_added, Now()) >10, Truepart, Falsepart)
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  8. #8
    armyofdux is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    55
    Is that syntax able to be used as a criteria in a query? The Immeadiate IF syntax is right but the truepart/falsepart threw me a curveball. I already know what I want it to do and that is copy the selected fields in accordance with the building of the append query. Am I missing something?

  9. #9
    armyofdux is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    55
    .....errors

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    put a field in your append query:

    Indicator: IIF(Datediff("s", Date_added, Now()) >10 , 1, 0)

    set the criteria of this field to 1

    Your query should show only records that are older than 10 seconds

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Why are you 'copying' data? What do you mean by 'copy the selected fields'?

    If you just need to append data from form into a table, why do you need filter criteria? I really don't understand your criteria of 10 seconds. Copy a record to another table 10 seconds after it was created?
    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.

  12. #12
    armyofdux is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    55
    Quote Originally Posted by June7 View Post
    Why are you 'copying' data? What do you mean by 'copy the selected fields'?

    If you just need to append data from form into a table, why do you need filter criteria? I really don't understand your criteria of 10 seconds. Copy a record to another table 10 seconds after it was created?
    The reason for the ten seconds is so that I don't get a litany of popups about records that are already present. Thus the ten seconds would only give me that particular record. Unless there is an easier way to do it.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Easier way is to use unique record ID as criteria.
    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. DateAdd Function
    By jschlapi in forum Forms
    Replies: 4
    Last Post: 10-23-2013, 01:36 PM
  2. Open Report w DateAdd function
    By libraccess in forum Programming
    Replies: 3
    Last Post: 02-21-2013, 12:31 AM
  3. DateAdd function for workdays?
    By 10 Gauge in forum Programming
    Replies: 2
    Last Post: 04-06-2011, 09:20 AM
  4. DateAdd Function
    By Desstro in forum Programming
    Replies: 3
    Last Post: 04-03-2011, 01:45 PM
  5. Help Please - DateAdd Function
    By graviz in forum Queries
    Replies: 3
    Last Post: 03-02-2010, 02:34 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