Subform data cannot sort (ascending) according to data (from non-primary key field) f

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GoVikings
    New Member
    • Sep 2015
    • 3

    Subform data cannot sort (ascending) according to data (from non-primary key field) f

    Hi

    Using MS Access 2010. Total newbie. Avoid using VBA where possible, always use the macro builders/expression builder.

    I have a source table with:
    ID - autonumber (primary key)
    Name - text

    Then I have a subform which displays multiple names from the source table. When I ask that subform sort the information, it does so according to the ID number data, not the alphabetical order of the Names data.

    Many names in the source table are repeated, so I cannot use the Name field as primary.

    Thanks for any guidance, it's driving me crazy =)
  • hvsummer
    New Member
    • Aug 2015
    • 215

    #2
    Did you try to sort by name field ? if you want that name field sort by alphabetical order, you have to sort by it. And I don't think duplicate data will effect much overall. I alway sort by duplicate data since it's my classification of other data.

    There're noway you could force ID field to sort that name field by alphabetical order as far as I can image.

    Comment

    • GoVikings
      New Member
      • Sep 2015
      • 3

      #3
      Hi hvsummer

      I did try to sort by the name field, both in the source table and then in the "record source" property of the subform (where I indicated to sort ascending by Name from the source table). But still, even though I ask to sort by Name, it seems bound to the ID number when sorting...

      Comment

      • GoVikings
        New Member
        • Sep 2015
        • 3

        #4
        I found a solution, at least in my case. The primary key (autonumber) was the basis for the sort, regardless of what I asked for in my query. I have no idea why this is, but when I made the Name field = primary key, and sorted again, it worked. Of course, I am fortunate because there are no duplicate names - if there were, I'm not sure what I would do.

        Comment

        • hvsummer
          New Member
          • Aug 2015
          • 215

          #5
          @GoViking: nice, if there were any duplicate names, still sort like you want row by row, don't worry.
          in my database, the thing that I avoid the most is primary key, annoying function...

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            I'm sorry to say that I can't agree. Nice it is not. Not unless you like problems and would like to encourage them to occur in your project.

            My advice would be to go back a step or two and explain why and where your name sorting failed before you made it PK. Check the field type. The only idea I have to explain this strange behaviour is that the name may have been set as a Memo field, which would be bad news in so many ways.

            NB. At this stage I should mention that making it indexed (Not unique, so duplicates must be Yes.) may well be a step forward even if making it PK certainly isn't.

            I hear that you're not very experienced so we can go slowly and carefully, but I strongly advise you not to leave it as is.

            Comment

            • hvsummer
              New Member
              • Aug 2015
              • 215

              #7
              @NeoPa: yeah,He should not let's it do wrong too long.

              but I don't think it bring only trouble. I use my language on SQL and I have to deal with alot of trouble, and It increase my creative.
              I don't think viking should follow me, but he can choose his path.

              I think he should get some problem when he left it like that to collect more experience. I got a lot experience when dealing with those funny problem ==

              let say in my database, query has SQL with non standard ISO, with space, and even non ACSII character like "Á, Ô, Ù" in my language.
              And the result is I can't code the VBA string in VBA since VBA does not support my language's character. and what did i do, I don't stop my self and say this is enough for me, I think hardly and then it pop up in my mind.
              I save SQL string with nonStandard and non ACSII in a table with ID, then call it out with Dlookup inside VBA, my problem gone.

              the point is I think GoViking want make some creative too ;) and he can collect more experience upon resolving tiny problem.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                That may well be true, and congratulations to you for overcoming your problems.

                However, we're not here to lead people into the wrong ways of doing things. If they manage to do that on their own, and grow due to finding a solution, then that's some benefit. Our aim here though, is to help those of you who are less experienced than we are, and guide you into sensible and database-oriented ways of doing things that will leave you - all readers - with a better understanding of the subject and better techniques with which to deal with your problems.

                It's a very basic and simple concept. We're here to help people and guide them in a helpful direction.

                Comment

                Working...