Results 1 to 2 of 2
  1. #1
    brennan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    1

    Link Records


    Hi, I have a table with 3 columns and records look like this

    Job Number Predecessor Job Num Successor Job Num
    1 2
    2 1 3
    3 2 4, 5
    4 3
    5 3
    6 10 11

    My task is to get a list of job dependencies based on the input job number.
    For example, if job number 2 is selected, the queries should return the first 5th rows because:

    job 1 is the predecessor to job 2
    job 3 is the successor to job 2
    job 4 & job 5 are successors to job 3, which job 3 is successor to job 2

    job 6 should not get selected because job 6, 10and 11 are not dependent on job 1,2,3,4, or 5

    Could you please provide a hint how to do it? Is there any faster way to prepare the list?

  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
    I know I worked with another poster on this kind of issue, maybe last year. Doubt I will ever find it again.

    In this case, the multiple values in one field complicates. Is this just a text string or is it a multi-value field? I changed the 4, 5 data to just 4 so I could test a query. The following works with the example dataset.

    SELECT Table1.JobNumber, Table1.Predecessor, Table1.Successor
    FROM Table1, (SELECT Table1.JobNumber, Table1.Predecessor, Table1.Successor
    FROM Table1
    WHERE (((Table1.JobNumber)="2"))) AS Query1
    WHERE (((Table1.JobNumber)=[Query1]![Predecessor])) OR (((Table1.JobNumber)=[Query1]![Successor])) OR (((Table1.JobNumber)=[Query1]![JobNumber])) OR (((Table1.Predecessor)=[Query1]![Predecessor])) OR (((Table1.Successor)=[Query1]![Successor])) OR (((Table1.Predecessor)=[Query1]![Successor])) OR (((Table1.Successor)=[Query1]![Predecessor]));

    Your solution might require VBA
    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: 8
    Last Post: 06-08-2012, 02:27 PM
  2. Replies: 2
    Last Post: 12-20-2011, 07:33 AM
  3. Replies: 1
    Last Post: 08-13-2011, 04:17 PM
  4. Link Records in the Same Table
    By threepwoodjr in forum Database Design
    Replies: 4
    Last Post: 03-17-2011, 06:33 AM
  5. Update query for ID #s to link records
    By fspswen in forum Queries
    Replies: 0
    Last Post: 11-20-2009, 01:52 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