combobox & text length

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blad3runn69
    New Member
    • Jul 2007
    • 59

    combobox & text length

    hi, just wondering how you good peoples get around combobox width and text length, in the context of making it easy for the user to read a long string?
    like this example

    Thanks for your help it is always greatly appreciated.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    I just sent an E-Mail to the Author of that code, Randy Birch, asking him permission to post as well as modify his code. If he accepts, I'll create a Procedure which should make what you are requesting very easy. Keep in touch.

    Comment

    • blad3runn69
      New Member
      • Jul 2007
      • 59

      #3
      cool stuff, kudos to you Adezii, thanks! Will stay tuned...

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by blad3runn69
        cool stuff, kudos to you Adezii, thanks! Will stay tuned...
        Just keeping in touch, no Reply from Mr. Birch as of yet.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by blad3runn69
          cool stuff, kudos to you Adezii, thanks! Will stay tuned...
          Sorry blad3runn69, but no response to your question will be forthcoming. Mr. Birch did reply and approve my request, but as I was writing the code I made one very biggggggggggg mistake. The code depends exclusively on the hWnd (Handle) Property of a Combo Box. In Access VBA only Forms and Reports have a hWnd Property. Sorry for the mistake - my oversight!

          Comment

          • blad3runn69
            New Member
            • Jul 2007
            • 59

            #6
            thanks for the help and information Adezii, no apologies needed.
            you guys always remind me how much I have to learn!
            take care out there

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by blad3runn69
              thanks for the help and information Adezii, no apologies needed.
              you guys always remind me how much I have to learn!
              take care out there
              I contacted Mr. Randy Birch on this matter, since it was his code originally, and asked if the code could possibly be ported to Access. He suggested I contact Mr. Dev Ashish since he frequently uses Randy's code in the hope that what you are requesting can actually be accomplished. I'm waiting for a reply from Mr. Ashish. Any major breakthroughs, you'll be the first to know.

              Comment

              • missinglinq
                Recognized Expert Specialist
                • Nov 2006
                • 3533

                #8
                You know, I thought the original question was

                Originally posted by blad3runn69
                how you good peoples get around combobox width and text length, in the context of making it easy for the user to read a long string
                And I think the answer to that, for probably 99.9% of the regulars here, is that we adjust the width of the combobox when we set it up so that it accommodates the longest item we expect to be displayed, rather than spending days trying to figure out some clever hack to dynamically size it. Occasionally we make adjustments, if need be. But basically, it's called planning ahead!

                Linq ;0)>

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #9
                  Originally posted by missinglinq
                  You know, I thought the original question was



                  And I think the answer to that, for probably 99.9% of the regulars here, is that we adjust the width of the combobox when we set it up so that it accommodates the longest item we expect to be displayed, rather than spending days trying to figure out some clever hack to dynamically size it. Occasionally we make adjustments, if need be. But basically, it's called planning ahead!

                  Linq ;0)>
                  Sorry Linq, but I disagree with you on this one. Few things look uglier that a 5" Combo Box on a Form placed there to accommodate a couple of entries which happen to be 4.75", not to mention the lost real estate. This functionality definitely has its uses, and is easily accomplished in Visual Basic. The problem lies it that it is not easily ported into Access VBA which effectively seems to ignore the Message sent to the Combo Box's Window Procedure. Maybe it can be accomplished and maybe not, but I do think that it is well worth the effort.

                  Comment

                  • mshmyob
                    Recognized Expert Contributor
                    • Jan 2008
                    • 903

                    #10
                    I think I may have figured out how to do this. I just want to test it a bit more and document it then I will upload the solution. Maybe by Sunday evening since I have to go out now.

                    cheers,

                    Comment

                    • mshmyob
                      Recognized Expert Contributor
                      • Jan 2008
                      • 903

                      #11
                      Ok done sooner than I expected. See attached.

                      You can clean the code up but I left it without modules to make it simple to understand.

                      Everything was done with pure VBA no external libraries or such.

                      I saved it in AC 2002-2003 format.

                      This will dynamically change the drop down list width of a combo box to accomodate the longest value. No need for user interaction or hard coding.

                      Hope this helps you.

                      cheers,
                      Attached Files

                      Comment

                      • ADezii
                        Recognized Expert Expert
                        • Apr 2006
                        • 8834

                        #12
                        Originally posted by mshmyob
                        Ok done sooner than I expected. See attached.

                        You can clean the code up but I left it without modules to make it simple to understand.

                        Everything was done with pure VBA no external libraries or such.

                        I saved it in AC 2002-2003 format.

                        This will dynamically change the drop down list width of a combo box to accomodate the longest value. No need for user interaction or hard coding.

                        Hope this helps you.

                        cheers,
                        Thanks for sharing your success with us, I'll have a look at it tomorrow.

                        Comment

                        • mshmyob
                          Recognized Expert Contributor
                          • Jan 2008
                          • 903

                          #13
                          I noticed a minor bug ... I mean undocumented feature.

                          If you have the code in the MouseDown event Access messes up in the sense that you cannot use the selected values.

                          If you take the code out of the MouseDown event and put it in the form open event or a button click event etc. everything works as it should.

                          cheers,

                          Comment

                          • ADezii
                            Recognized Expert Expert
                            • Apr 2006
                            • 8834

                            #14
                            Originally posted by mshmyob
                            I noticed a minor bug ... I mean undocumented feature.

                            If you have the code in the MouseDown event Access messes up in the sense that you cannot use the selected values.

                            If you take the code out of the MouseDown event and put it in the form open event or a button click event etc. everything works as it should.

                            cheers,
                            Hello mshmyob, congratulations on a rather ingenious and intuitive Method of dynamically adjusting the Drop Down List Width of a Combo Box, without accessing the API! I still think that this functionality is very useful and can be applied in varied circumstances. I would like to have your express permission to perform the following actions:
                            1. Modify your code which would primarily consist of cosmetic changes such as changing the Naming Conventions, move it out of the MouseDown() Event, syntax changes, changing the Form. and perhaps making it more Modular.
                            2. Once these changes have been made, and after your express approval, upload the code to Mr. Randy Birch, a Microsoft MVP (Most Valuable Professional). I've been in contact with Mr. Birch since the beginning of this Thread when I was attempting to port his VB.Net code to Access VBA, in the hopes of finding a solution to your dilemma. Mr. Birch also works hand-in-hand with Dev Ashish, but I have not received a reply from him regarding porting the code. I'm sure that Mr. Birch would be very interested to know that you have successfully resolved the problem on your own, and possibly pass this information, and code, down the line.
                            3. I would also like to make sure that you receive full accreditation for the code. Ideally, I would prefer to have your real name, and possibly a plug for the Bytes IT Community in the code credits. Of course, I would have to get permission from Mary and/or NeoPa before I would attempt this. If you do not wish to release your real name, your Alias will do fine with a reference to Bytes so that when you become famous and the royalties roll in, people will know where to contact or reach you (LOL).
                            4. I am going on vacation for 6 days and will take no further action on this matter until I hear from you. I will be checking in from time to time if I can access a PC with Internet Access, and I really would appreciate it if you could give me a response on points 1, 2, and 3 mentioned previously. Take care, and again, nice job.

                            Comment

                            • mshmyob
                              Recognized Expert Contributor
                              • Jan 2008
                              • 903

                              #15
                              Hello ADezi,

                              Yeah sure modify it to your heart's content. By the way it was not me who had the problem originally. The original OP was Blade.

                              My real name is ** Removed **. Yeah and give a plug to Bytes. After you make the modification please upload again. Check my previous post about the mousedown event.

                              cheers,
                              Rob
                              Last edited by NeoPa; Aug 4 '08, 11:58 AM. Reason: Removed name for member's security

                              Comment

                              Working...