Results 1 to 8 of 8
  1. #1
    Rabastan99 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5

    Change ID to Name in Query

    I have have a that shows hierarchic data.




    stepID
    parentID
    stepName


    The Parent ID is the step that comes before it in the list, it however is stored as a number. I need to export this data to excel, how would I create a query that will export it with the name and not the ID?


    Rab

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Don't understand this data structure. Provide example of data. If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    Rabastan99 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5
    OK No problem. The database is to map steps in trouble shooting processes. The eventual out come is to print them out in a flow chart.

    DataExample1.zip

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I still don't understand "Parent ID is the step that comes before it in the list".

    I don't see a ParentID field, just stepParentID.

    Where should the 'name' come from?

    Perhaps example of desired output from the example data would help.

    Consider:

    Query1 - ParentIDs
    SELECT tblProcessStep.stepID, [stepID]-1 AS ParentID FROM tblProcessStep;

    Query2 - ParentNames
    SELECT ParentIDs.stepID, ParentIDs.ParentID, tblProcessStep.stepName AS ParentName
    FROM tblProcessStep INNER JOIN ParentIDs ON tblProcessStep.stepID = ParentIDs.ParentID;

    Query3
    SELECT tblProcessStep.stepID, tblProcessStep.ProcedureID, tblProcessStep.stepParentID, tblProcessStep.stepName, ParentNames.ParentName
    FROM tblProcessStep LEFT JOIN ParentNames ON tblProcessStep.stepID = ParentNames.stepID;

    This presumes the unique stepID field is sequential with no gaps.
    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
    Rabastan99 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5
    It is quite possible you don't understand because I blew the entire design from the beginning.

    The database will store about 40-50 flowcharts for various troubleshooting procedures.

    All the steps are in the same table, with the ID of the step that comes before it named "ParentID". So the "ParentID" is the "stepID" of the step that came before it.

  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,931
    You may have read my previous post before I edited. Might look at again.
    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
    Rabastan99 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    5
    The data is not sequential by any means

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    My suggestion requires a field or combination of fields that can be used to sort the records into proper order and a field or fields that can be used to calculate the unique ParentID. I used the unique stepID field for both. Requires that the stepID be sequential without gaps.

    If the stepID does not sort records into proper hierarchical order and/or has gaps, you have a big problem.

    The suggested query will only go the one level. Surely the decision process would be many levels. I've never seen a Access database for this purpose. It's probably not an easy database to construct.

    As for printing into a 'flow chart', have doubt Access is best tool for this. Might look at MS Visio. It can pull data from Access. Or something like Visio: http://www.smartdraw.com/specials/ppc/flow-chart.htm?id=45104&gclid=CL3m1tCcv8ECFQaNaQodCRAAj Q

    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: 2
    Last Post: 10-03-2014, 10:07 AM
  2. refer to a query in vba to change its sql?
    By Ruegen in forum Queries
    Replies: 31
    Last Post: 12-05-2013, 07:31 PM
  3. Replies: 3
    Last Post: 07-20-2012, 11:41 AM
  4. Change Name of field within Query
    By bkelly101 in forum Access
    Replies: 1
    Last Post: 06-23-2011, 06:56 AM
  5. Query to change all data
    By justinwright in forum Queries
    Replies: 18
    Last Post: 09-01-2010, 08:41 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