Results 1 to 3 of 3
  1. #1
    xtrmsound is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2014
    Posts
    1

    alphabetical order from different fields.

    Hello,

    I'm trying to build a report that will give me a list of names alphabetically from different fields inside one table.
    My table contains these fields: Dorm, Room number, Name 1, Name 2, Name 3, Name 4 and name 5.

    I want to build a report that will give me the names of each participant alphabetically with the Dorm and room number.


    It should look like that

    Dorm A, Room 1, A
    Dorm C, Room 3, B
    Dorm B, Room 2, C

    How can I do it. I tried to google it, but I couldn't find how to do it in more than one field.

    I attached an excel file that shows an example of the table.


    Thank youexample.xlsx.zip

  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,944
    The data is not normalized structure. Normalization would require another table for the names assigned to the dorm/room. Are you saving name or ID into the NameX fields?

    tblRoomNames
    DormRoomID
    NameID

    Otherwise, use a UNION query to rearrange the names into normalized structure. Must type or copy/paste into SQL View of query builder.

    SELECT Dorm, Room, 1 AS Source, [Name 1] AS Resident FROM tablename
    (the forum is not letting the rest of the UNION query to post - weird, I will try again later)

    Now use that query as a source for subsequent queries.
    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
    fredz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    19
    I agree with June7, your data is not in a "normalized" design. You can expect to have similar difficulties as your application evolves over time and you desire new reports/features.

    Nevertheless, to attack this problem, you might create 5 separate queries and then union them together.
    Example:

    Select Dorm, Room, Name1 From tblData
    Union
    Select Dorm, Room, Name2 From tblData
    Union
    Select Dorm, Room, Name3 From tblData
    Union
    Select Dorm, Room, Name4 From tblData
    Union
    Select Dorm, Room, Name5 From tblData

    Then you can use this unionquery as your recordsource and sort by name.
    (It will likely be slowwwwww).

    Fred

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

Similar Threads

  1. alphabetical order of lists
    By FB93 in forum Access
    Replies: 1
    Last Post: 03-27-2014, 06:23 PM
  2. Why is my form opening in alphabetical order?
    By Access_Novice in forum Forms
    Replies: 6
    Last Post: 12-10-2013, 05:22 PM
  3. Records are not in alphabetical order
    By snowboarder234 in forum Forms
    Replies: 3
    Last Post: 04-12-2012, 03:30 PM
  4. Combo Box in Alphabetical order
    By jordanturner in forum Forms
    Replies: 2
    Last Post: 09-24-2010, 08:02 AM
  5. omit word in entry for alphabetical order
    By airhud86 in forum Access
    Replies: 1
    Last Post: 12-14-2009, 03:49 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