Results 1 to 10 of 10
  1. #1
    80.vikas is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    5

    Fill blank in table with data from previous row

    Hi,

    Can anyone suggest me how can I fill blank cell from data in previous row in Access Table.
    Update Flag in attached file with value in Previous row.

    Thanks
    Vikas
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    Can't do it in table. Use form. Review this http://allenbrowne.com/ser-24.html
    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
    80.vikas is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    5
    Please suggest something that can be handle with Query and not with use of form.

    Quote Originally Posted by June7 View Post
    Can't do it in table. Use form. Review this http://allenbrowne.com/ser-24.html

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    You can run an INSERT SELECT query. The query would have to find the most recent record in table and then insert new record with values from the selected record. Is this a multi-user database?

    If you are working directly with tables, can just select the entire row and do copy/paste into new row.
    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
    80.vikas is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    5
    Can you please sugget how to run Insert query in database in attached file .

    No, this is single-user database. But still don't want to update manually, since data is quite huge and needs daily updation.

    Quote Originally Posted by June7 View Post
    You can run an INSERT SELECT query. The query would have to find the most recent record in table and then insert new record with values from the selected record. Is this a multi-user database?

    If you are working directly with tables, can just select the entire row and do copy/paste into new row.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    The SQL is like:

    INSERT INTO Test (Flag) SELECT Flag FROM (SELECT Flag FROM Test WHERE ID=(SELECT Max(ID) As MaxID FROM Test)) As Q1;

    Review http://msdn.microsoft.com/en-us/library/ms188263.aspx
    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
    80.vikas is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    5
    Insert is not working. I need to update particular values.

    Original date
    ID Flag
    1 Fixed
    2
    3 Variable
    4

    Data required
    ID Flag
    1 Fixed
    2 Fixed
    3 Variable
    4 Variable

    I want to do this on recurring basis, so I think I need to use Module option that can be linked with Table Query and dont want this with form.


    Option that I can think of is creating new function using SQL, something like below:

    Sub Sort()


    Dim Rs As Recordset
    Dim RsSql As String
    'Create a snapshot of data from your table with the desired fields and data
    RsSql = "Select ID, SORTDATE1 From Dates2 Where ID IS NOT NULL"
    'Where Condition = '" & Criteria & "'"
    'Open the recordset
    Set Rs = CurrentDb.OpenRecordset(RsSql)
    'Destroy the instance of the recordset from memory
    Set Rs = Nothing
    End Sub

    But I dont know if :
    1. Above query is correct
    2. Also, how to call this in Table query.

    Can you please create above sturcture in my Access file and send back to me.



    Quote Originally Posted by June7 View Post
    The SQL is like:

    INSERT INTO Test (Flag) SELECT Flag FROM (SELECT Flag FROM Test WHERE ID=(SELECT Max(ID) As MaxID FROM Test)) As Q1;

    Review http://msdn.microsoft.com/en-us/library/ms188263.aspx

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    Review this article http://allenbrowne.com/subquery-01.html especially the section 'Get the value in another record'
    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.

  9. #9
    80.vikas is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    5
    Can you please provide suggest me how can I use below in my access file?

    Quote Originally Posted by June7 View Post
    Review this article http://allenbrowne.com/subquery-01.html especially the section 'Get the value in another record'

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    Having a record get value from another record is not simple.

    Never tried anything like this. Possibly:

    1. Build query using Allen Browne's query syntax that gets the value from other record

    2. Use that query in an UPDATE query on the original table. The query would include join on the table and the first query so that the value will be available for the UPDATE TO row of the query grid. Review Help on how to build UPDATE where the update value comes from another table/query.

    Try:
    query 1: PriorValue
    SELECT Test.ID, Test.Flag, (SELECT Flag FROM Test As Dupe WHERE Dupe.ID = Test.ID-1) AS PriorValue FROM Test;

    query 2: couldn't get a join to work so used DLookup
    UPDATE Test SET Test.Flag = DLookUp("PriorValue","PriorValue","ID=" & [ID]) WHERE (((Test.Flag) Is Null));
    Last edited by June7; 03-17-2012 at 02:03 AM.
    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: 1
    Last Post: 12-21-2011, 02:11 PM
  2. Replies: 1
    Last Post: 12-09-2010, 08:29 AM
  3. Replies: 12
    Last Post: 08-09-2009, 07:35 AM
  4. Add data from previous record if blank
    By mbc321 in forum Queries
    Replies: 1
    Last Post: 08-08-2009, 05:15 PM
  5. Replies: 3
    Last Post: 10-23-2008, 08:43 AM

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