Results 1 to 6 of 6
  1. #1
    Ucpaul is offline Novice
    Windows Vista Access 2013
    Join Date
    Apr 2015
    Location
    Atlanta
    Posts
    3

    Coding and Order in Access Query

    Hello,



    I need to create a column from Access Query that assign Code =1 to the last number of each series (in column Trip_ID). I also need to create a column to order records (please see attached example). I need to do it in Access, not Excel.

    I appreciate any help.

    Thanks
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,642
    I think what you want is virtually impossible in query with the data shown. There is no way to distinguish records within a group from each other. Is there a unique ID field in table?
    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
    Ucpaul is offline Novice
    Windows Vista Access 2013
    Join Date
    Apr 2015
    Location
    Atlanta
    Posts
    3
    There is no unique ID. I want to mark the last number whenever the series changes value. Thanks

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,642
    Records in table have no inherent order. All the records in a series are the same. It's irrelevant to Access which is 'last' or 'first' - Access cannot 'see' last/first record in series because they all look the same, therefore they are all last/first.

    Why is this needed? Why are there multiple identical records? What are you really trying to accomplish?
    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
    Ucpaul is offline Novice
    Windows Vista Access 2013
    Join Date
    Apr 2015
    Location
    Atlanta
    Posts
    3
    I need to mark when the series changes. I could do it easily in Excel. If TRIP_ID is in column A, then : Cell B1=if(A1<>A2,1,"").

    But I need to do it in Access because other connections and cannot explain here. Thanks

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,642
    The Trip_ID itself is an indicator the series changes.

    If the ultimate goal is to generate a dataset of unique trip IDs, that can be done by:

    SELECT DISTINCT Trip_ID FROM tablename;

    or

    SELECT TRIP_ID FROM tablename GROUP BY TRIP_ID;

    That's about all I can offer without a better understanding of this situation.
    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. Access Query Sort Order every other one
    By Gina Maylone in forum Access
    Replies: 2
    Last Post: 09-29-2014, 11:26 AM
  2. Help with access 2010 coding
    By framar in forum Access
    Replies: 5
    Last Post: 12-30-2012, 01:26 PM
  3. Replies: 1
    Last Post: 12-19-2012, 10:46 PM
  4. Need Help with Access vb coding
    By Entrimo in forum Access
    Replies: 1
    Last Post: 02-19-2012, 06:15 PM
  5. Access without coding
    By kp123 in forum Access
    Replies: 4
    Last Post: 11-25-2011, 03:50 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