Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142

    Custom Sorting Methods for End User?

    I will frequently require itemized lists for output to reports. The user will need to be able to arbitrarily customize the sort order of these items. That is the items won't necessarily be sorted by date/time or alphabetically or any predefined logical order. The user needs to be able to say this item is at the top of the list, this item goes before that one, this other one goes before that one, etc. Arbitrary sort order.



    I figure at the time of reports that there will be line numbering but that will be handled dynamically by the report. BUT the reports could just be bullet point lists and not numbered lists.

    So my question is what is the most efficient method to save custom arbitrary sort orders in the database?

    At first thought I would simply have a SortOrder field in the table of an integer datatype. They would simply be sequential integers the report queries could sort by, and when the user moved an item around in the sort order I'd have a procedure to move the rest of the items in the list appropriately to make room. The user would have access to directly edit this integer. But I'm wondering if it would be wiser to use floating points. Each time an item is added to the list the SortOrder = previous item's SortOrder + an arbitrary large number. When an item is moved up and down the list instead of changing the SortOrder field of every item in the list that is affected all I'd have to do is make the SortOrder # of the item I'm moving greater than the item i'm moving it behind, and less than the item im moving it in front of.

    For example:
    Step 1) I add the first item A to the table and vba assigns arbitrary sort order # 1.0
    Step 2) I add another item B with sort order # 1000.0
    Step 3) I add another Item C with sort order # 2000.0

    If I want to move C between A and B I simply set C's sort order # to (1.0 + 1000.0)/2=500.5. Of course the math would be handled behind the scenes and the user would never see the actual sort order field value. And as for UI i'm guessing something like a listbox where they select the item and have up and down command buttons to move the item up and down the list...

    Any thoughts/issues? Examples? I'm guessing this has been done before, I don't want to reinvent the wheel over here.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Is this a multi-user db? Cannot use the original data table to assign sort order to each record. Would be conflicts between simultaneous users.

    Really should be saving user choices to a table. If you want to maintain history of these choices the records would be permanent, otherwise use a 'temp' table where records reside long enough to complete a process and then purged.
    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
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by June7 View Post
    Is this a multi-user db?
    Not at the moment but we're open to the possibility in the future. I'll say there shouldn't be multiple users editing/entering data at the same time.

    Cannot use the original data table to assign sort order to each record. Would be conflicts between simultaneous users.
    Can you elaborate on how/why things would conflict? I'll admit my experience with multi user access apps is none at the moment, about the only thing I know is I need to split the db and use a different FE for each user.

    I don't know if this makes a difference but the way I'm figuring it at the moment is when a user clicks a button "Move Up" or "Move Down" the button will call a Sub that will Dim a new recordset, make necessary changes to the sort column, save and close the recordset. In other words it's not hanging open for any significant length of time.

    Again, I don't really have much of an understanding of the nuances of multi user environment...

    Really should be saving user choices to a table. If you want to maintain history of these choices the records would be permanent, otherwise use a 'temp' table where records reside long enough to complete a process and then purged.
    I do need to maintain a sort order and was planing on saving it to the table.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Cannot use the original data table to assign sort order to each record.
    You can if the sort isn't user based. I may have missed where the OP says it is, but I read it more than once and don't see where that was declared. It could be that if you make an initial sort and I add data, I should be able to insert my records in between yours and the desired sort would still be maintained. If you see where I made a mistake in my sort, then you should be able to correct it. If that isn't the situation, then I agree.

    I have used sort order fields based on increments of 100 but didn't apply any calculation to determine the next ordinal number. Sounds like a good idea to find the mid point between two records. If you're talking about a LOT of records eventually and you happen to run out of positions, you could use a multi-field sort where the 1st is alpha. Just don't use integer data type for your sort field.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    You propose field in the data table where user would assign a value for sort order. If there are multiple simultaneous users trying to change data in the same records, which should have precedence?
    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.

  6. #6
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by June7 View Post
    You propose field in the data table where user would assign a value for sort order. If there are multiple simultaneous users trying to change data in the same records, which should have precedence?
    Which user should have precedence? I guess I don't understand why this scenario is any different than a user entering any other data in the record. ?

  7. #7
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by Micron View Post
    You can if the sort isn't user based. I may have missed where the OP says it is, but I read it more than once and don't see where that was declared. It could be that if you make an initial sort and I add data, I should be able to insert my records in between yours and the desired sort would still be maintained. If you see where I made a mistake in my sort, then you should be able to correct it. If that isn't the situation, then I agree.

    I have used sort order fields based on increments of 100 but didn't apply any calculation to determine the next ordinal number. Sounds like a good idea to find the mid point between two records. If you're talking about a LOT of records eventually and you happen to run out of positions, you could use a multi-field sort where the 1st is alpha. Just don't use integer data type for your sort field.
    The sort order is not supposed to be unique to different users if that's what you all mean.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    How about giving us a real life example of the types of sort you think you will encounter?

    People are guessing ----- let's work with a sample.

  9. #9
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Let's say I'm creating a quote to send to a customer. I have a report that will generate the quote on company letterhead. The quote will have multiple lists of qualifications. Each qualification is a "list item", a quote can have dozens or more of qualifications.

    I list of qualifications might look like the following

    ...
    Included in this quote:

    1. Floor Framing
    2. Wall Framing
    3. Roof Framing
    4. Windows
    5. HVAC
    6. Plumbing

    ...

    The person preparing the quote needs to be able to arbitrarily move line items around in this list.

    [Edit]

    And let's say that list was generated from a qualifications table that looks like this:

    Qualifications
    QualID as AutoNumber
    QualDescription as Short Text
    QualSortOrder as Number
    QuoteID as Number (foreign key)

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Well,
    The user will need to be able to arbitrarily customize the sort order of these items.
    means to me the sort will be dynamically defined by each user. Which seems to be contradictory to
    The sort order is not supposed to be unique to different users if that's what you all mean.
    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.

  11. #11
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by June7 View Post
    Well, means to me the sort will be dynamically defined by each user. Which seems to be contradictory to
    A user will define the order of the list but the order is not dependent on which user is looking at it. The order is what it is for everyone. If I move an item from the middle of the list to the top of the list that's where it goes, for everyone! I'm not sure we're on the same page?

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    So I presume you have Quotes and QuoteDetails tables where user enters record(s) and defines sort order for that subset of records. I expect more than one way to skin this cat. Pick one and go for it.
    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.

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I remember writing some code to move an Item up or down in a listbox. Don't know if it applies.

    Click image for larger version. 

Name:	ReOrderList.png 
Views:	19 
Size:	9.4 KB 
ID:	33103

  14. #14
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by June7 View Post
    So I presume you have Quotes and QuoteDetails tables where user enters record(s) and defines sort order for that subset of records. I expect more than one way to skin this cat. Pick one and go for it.
    Lol! Thanks I guess In all sincerity I do appreciate you taking your time to look at this.



    So my question is what is the most efficient method to save custom arbitrary sort orders in the database?
    Any thoughts/issues? Examples? I'm guessing this has been done before, I don't want to reinvent the wheel over here.

  15. #15
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by orange View Post
    I remember writing some code to move an Item up or down in a listbox. Don't know if it applies.

    Click image for larger version. 

Name:	ReOrderList.png 
Views:	19 
Size:	9.4 KB 
ID:	33103
    Yep, that's what I'm after! Assuming the order in the list is saved to the backend.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Custom Grouping & Sorting (pics attached)
    By Eirini_kap in forum Reports
    Replies: 8
    Last Post: 02-03-2016, 11:00 AM
  2. custom sorting with IIF statement
    By orangeman2003 in forum Access
    Replies: 5
    Last Post: 05-13-2014, 03:38 PM
  3. Custom sorting records in report
    By tanyapeila in forum Reports
    Replies: 4
    Last Post: 03-26-2014, 12:32 PM
  4. Custom User Group queries
    By EliOklesh in forum Security
    Replies: 2
    Last Post: 10-29-2011, 01:12 PM
  5. User Defined Sorting in Form
    By sparlaman in forum Forms
    Replies: 6
    Last Post: 04-26-2011, 12:02 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