Results 1 to 11 of 11
  1. #1
    hnorgaar is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Posts
    19

    Reorganising data in table field

    Need a bit of help to arrange data in a comma based text field, guess by doing a query and create a table from that

    Have "100HK, 122HK, 80HK, 90HK"

    And would like like that to be sorted by number and end up with



    "80HK, 90HK, 100HK, 122HK"

    Help appreciated. Thx

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    You can use the Split() function to get the individual parts.
    The sort is up to you, Google for an array sort.
    Use & to concatenate back together.

    Not the best way to store data TBH?

    Or are you talking about putting each of those into their respective field per record, which is how I would have done it in the first place?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    hnorgaar is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Posts
    19
    hi there, thx for the response, but it actually comes from multi value selection in a form and ends up in a unassigned multi value field on my form, and then copied to a field assigned to a table. However the whole sorting aspect get messed up by being a text field when data need the HK in the end, where the data 100HK is smaller than 80HK. It is for a car database and the reason for doing this is there are many engines on the ame type of cars. BMW 320I with 90HP and 120HP and so on

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Most experienced Access developers avoid multi value fields like the plague.
    On 2007, they are not available.

    Sounds like you would need to write a function to do this any time that field is modified?, if you have to have it sorted like you are asking now?

    Really they should be in a separate table, so you would hold 120BHP and other relevant info for that engine, whether it is Diesel or Petrol etc, normally there would be an engine identifier ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Quote Originally Posted by Welshgasman View Post
    Most experienced Access developers avoid multi value fields like the plague.
    On 2007, they are not available.
    Actually they are available. The feature was introduced with A2007.
    See Multivalued Fields - Mendip Data Systems and Create or delete a multivalued field - Access (microsoft.com).
    Nevertheless, they should definitely be avoided.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Wow, never knew that , but they appear to be tied to lookup values, which after my first DB, I have also not used again.

    Thanks anyway Colin.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Quote Originally Posted by Welshgasman View Post
    Wow, never knew that , but they appear to be tied to lookup values, which after my first DB, I have also not used again.

    Thanks anyway Colin.
    I certainly don't want to encourage you to use MVFs but, as my article explains, they can be created either from a value list or from a lookup table
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  8. #8
    hnorgaar is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Posts
    19
    Quote Originally Posted by isladogs View Post
    I certainly don't want to encourage you to use MVFs but, as my article explains, they can be created either from a value list or from a lookup table
    And I dont know any other way to do it than with cascading lists and MVF. Im in the situation where I do have the data where every car have 1 engine and HP, but I need to combine the HP per Engine/Car for export to Excel and therefore have less lines/duplicates and in the end fewer articles for the custemer to choose from. Thx for the assistance

  9. #9
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Please have a look at the attached sample - query 1.

    Cheers,
    Vlad
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #10
    hnorgaar is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Posts
    19
    Thx Gicu, I learned something new today and solved that issue perfectly. Case closed

  11. #11
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    You're welcome!
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 2
    Last Post: 07-18-2021, 10:43 AM
  2. Replies: 1
    Last Post: 12-04-2016, 05:43 PM
  3. Replies: 3
    Last Post: 11-29-2016, 10:03 AM
  4. Replies: 1
    Last Post: 05-31-2015, 09:20 AM
  5. Replies: 2
    Last Post: 03-07-2013, 04: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