Results 1 to 5 of 5
  1. #1
    leonhuynh2006 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    9

    Last of Previous record

    Dear all bro and pro,

    Let say I have:
    OrderID Date
    1 1/1/2010
    2 15/1/2010
    3 25/1/2010
    4 30/1/2010

    Now, I would like to add a new row called previous date
    OrderID Date P.Date


    1 1/1/2010
    2 15/1/2010 1/1/2010
    3 25/1/2010 15/1/2010
    4 30/1/2010 30/1/2010

    Sorry for my english as I can not describe by english without illustration

    I am very appreciated for your helping

    Thanks & Regards

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I'd use VBA

    I don't know if your problem can be done with a query or SQL, but I've done this sort of thing using VBA.
    Assuming "mytable" is sorted in proper order:

    Dim rs as recordset
    dim temp as text
    set rs = currentdb().openrecordset("mytable", dbOpenDynaset)
    With rs
    .MoveFirst
    temp = !Datefld
    Do while not .EOF
    .MoveNext
    .Edit
    !LastRecDate = temp
    temp = !Datefld
    .Update
    Loop
    rs.Close

    Caution: I typed this without doing any error checking, you are only getting 90% of the story.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Here is a non VBA solution

    http://support.microsoft.com/kb/210504T

    BTW: The term Date is a reserved Access name. You should change the field name to something else. If you keep it, at some point it will confuse Access and give you problems.

    Alan

  4. #4
    leonhuynh2006 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    9
    Thanks for quick reply. However, my records are not followed by sequential order. I would like to do it by using query.

    Please helps. Thanks!!!

  5. #5
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    My apologies, I posted the wrong link for you.

    Here is a link that does what you want in a non VBA manner and in a query

    http://support.microsoft.com/kb/210504

    Alan

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

Similar Threads

  1. Replies: 8
    Last Post: 07-06-2013, 05:13 PM
  2. Previous record
    By leonhuynh2006 in forum Forms
    Replies: 1
    Last Post: 10-06-2011, 06:41 AM
  3. Replies: 1
    Last Post: 07-25-2011, 09:41 AM
  4. Replies: 1
    Last Post: 04-21-2011, 11:27 AM
  5. using value from previous record
    By dollars in forum Queries
    Replies: 0
    Last Post: 12-10-2008, 03:30 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