Results 1 to 4 of 4
  1. #1
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23

    fill blank cells of duplicate records

    Hi, I have a database with duplicate records IDs. I need the duplicates, each duplicate has different water quality data. I want to fill in the blanks of certain fields for each duplicate, where a record for that field occurs in any duplicate of the same record. I need to organise it this way as a statistical package i am using needs it all in one table.



    ID depth geology date data 1 data 2
    A 2 sand june A1.1x A2.1.x
    A august A1.2.x A2.2.x
    B janurary B1.1.X B2.1.X
    B 11 rock
    C 9 mud october C1.1.X

    I need the blanks for the depth and geology fields to be filled in and be the same value as any duplicate records for depth and geology. So to look like this:


    ID depth geology date data 1 data 2
    A 2 sand june A1.1x A2.1.x
    A 2 sand august A1.2.x A2.2.x
    B 11 rock janurary B1.1.X B2.1.X
    B 11 rock
    C 9 mud october C1.1.X

    Can anyone help with ways to achieve this using a query/sql? Part of the problem is that sometimes the duplicate field with the value is above the empty duplicate field, and sometimes it is below.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Will depth and geology always both be blank (or both not blank) for same record? Will there not be more than two records for each ID?

    If so, try something like:

    query DataNotNull
    SELECT Table1.ID, Table1.depth, Table1.geology
    FROM Table1
    WHERE ((Not (Table1.depth) Is Null)) OR ((Not (Table1.geology) Is Null));

    query DataNull
    SELECT Table1.ID, Table1.depth, Table1.geology
    FROM Table1
    WHERE (((Table1.depth) Is Null)) OR (((Table1.geology) Is Null));

    UPDATE DateNotNull INNER JOIN DataNull ON DateNotNull.ID = DataNull.ID SET DataNull.depth = [DateNotNull].[depth], DataNull.geology = [DateNotNull].[geology];
    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
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23
    Thanks for your reply. Yes depth and geology will always be blank or not blank in the same record, but sometimes there will only be 1 record, sometimes 2 duplicates, sometimes up to 15 duplicates. Each time however, regardless of how many duplicates there will only be one cell filled or depth and geology




    Quote Originally Posted by June7 View Post
    Will depth and geology always both be blank (or both not blank) for same record? Will there not be more than two records for each ID?

    If so, try something like:

    query DataNotNull
    SELECT Table1.ID, Table1.depth, Table1.geology
    FROM Table1
    WHERE ((Not (Table1.depth) Is Null)) OR ((Not (Table1.geology) Is Null));

    query DataNull
    SELECT Table1.ID, Table1.depth, Table1.geology
    FROM Table1
    WHERE (((Table1.depth) Is Null)) OR (((Table1.geology) Is Null));

    UPDATE DateNotNull INNER JOIN DataNull ON DateNotNull.ID = DataNull.ID SET DataNull.depth = [DateNotNull].[depth], DataNull.geology = [DateNotNull].[geology];

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Here's what I'd do. Create a query with your ID, DEPTH and GEOLOGY. put IS NOT NULL in both DEPTH AND GEOLOGY and browse through that to make sure there are no duplicates. If there aren't change the query to a summation query (look for the SIGMA, looks like a capital E, button on your ribbon). This should give you a shortened list of ID's Then create a query based on your table and this query you've created and instead of showing the DEPTH AND GEOLOGY from your main table link it to your query through the ID field and use the DEPTH AND GEOLOGY from your summation query.

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

Similar Threads

  1. Replies: 9
    Last Post: 03-16-2012, 01:03 PM
  2. Replies: 1
    Last Post: 01-10-2012, 09:47 PM
  3. Criteria to find when cells are blank
    By Badvgood in forum Queries
    Replies: 3
    Last Post: 12-06-2011, 06:14 PM
  4. Replies: 16
    Last Post: 11-02-2011, 01:35 PM
  5. Replies: 4
    Last Post: 12-13-2010, 05:33 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