Run-time Switching of Command Button Picture

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32668

    Run-time Switching of Command Button Picture

    What needs to be set and/or changed when switching the Picture property of a Command Button within VBA code?

    The scenario is that I have a continuous form for a particular table. The controls (in total) are too wide to fit easily on the form, so I have split the form into two (logically that is). Some controls are shown in mode A and the rest are shown in mode B. The Command Button I have that switches modes works fine (hiding and showing the relevant controls) but I can't find how to swap the Command Button Picture from [RightArrow (Blue)] to [Left Arrow (Blue)] and vice versa.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I tried to find the original bitmaps, alas I failed, couldn't find them in any of the logical choices.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32668

      #3
      Yeah, I did too. Thanks for looking anyway. Appreciated.

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Originally posted by NeoPa
        Yeah, I did too. Thanks for looking anyway. Appreciated.
        I've had problems in the past with this as well. It seems you can't directly access the bitmaps. I replaced the Access bitmaps with my own and it works fine.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32668

          #5
          Thanks Mary :)
          I'm not sure I want to go to all that trouble with this. I'm always nervous with images anyway. Not much experience there I'm afraid. I might have the two buttons and just show the one that's not in use.
          Last edited by NeoPa; Jan 17 '08, 11:09 PM. Reason: Added word show

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Hello NeoPa, sorry I jumped in late. The original Bitmaps that you are seeking reside in a 'shared' Office Pool in a Bitmap Slab. Office XP stores this hugh collection of Bitmaps as an Office-wide resource as a single 'slab' in one of its .DLLs. Storing them this way saves on Graphics Resources and in addition, Access provides its own set of extra Button Bitmaps mostly for historical purposes. Msaccess.exe provides a Method for retrieving a single Bitmap from the slab which involves an Index into this group of Bitmaps and the subsequent filling of a Byte() Array with the requested Bitmap. I've condensed a large amount of Code and Objects to a single Form, Query, and Module. This will give you the capability to either Save a specific Bitmap from the 'slab' to disk as a *.BMP, or to assign it to the Picture Property of an Object. This functionality will give you access to the 226 Bitmaps used by Access and the 5,700 used by Office. In your case, I assume that you may want to Save them to disk, then load them into selective Controls. I answered a similar Post in November and I'll now post the Link below which contains some of the previous explanations. I am going on vacation for a couple of days starting tomorrow, but if you like, I can send you the relevant code to Extract/Save the requested Bitmaps, then utilize them in your Database.
            Access Bitmaps - where are you?
            Last edited by NeoPa; Jan 14 '08, 01:18 PM. Reason: Removed other post

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32668

              #7
              I assume from the fact that you're offering a DB rather than explaining the process that it's a little bit "involved".

              Please do send the DB and I'll see if I can understand and use it. Where possible, I'm looking to avoid use of external items (items stored in DLLs etc) except where automatically handled in the application (API etc). If there is a procedure provided this may be useful. I'll have to dig in and have a look-see.

              Thanks anyway for your help ADezii.

              PS I'm assuming you already have my em address. If not just let me know & I'll PM it be reply :)

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #8
                The other option is to use two command buttons and toggle them visible/invisible as required.

                Comment

                • sierra7
                  Recognized Expert Contributor
                  • Sep 2007
                  • 446

                  #9
                  Originally posted by msquared
                  The other option is to use two command buttons and toggle them visible/invisible as required.
                  I endorse Mary's solution here.

                  I used to 're-cycle' command buttons and detect their current state/function by their Caption. I was forced out of this when I started to write multi-lingual applications and now realise it is much 'cleaner' to always keep one function per button.

                  S7

                  Comment

                  • ADezii
                    Recognized Expert Expert
                    • Apr 2006
                    • 8834

                    #10
                    Originally posted by NeoPa
                    I assume from the fact that you're offering a DB rather than explaining the process that it's a little bit "involved".

                    Please do send the DB and I'll see if I can understand and use it. Where possible, I'm looking to avoid use of external items (items stored in DLLs etc) except where automatically handled in the application (API etc). If there is a procedure provided this may be useful. I'll have to dig in and have a look-see.

                    Thanks anyway for your help ADezii.

                    PS I'm assuming you already have my em address. If not just let me know & I'll PM it be reply :)
                    I assume from the fact that you're offering a DB rather than explaining the process that it's a little bit "involved".
                    Actually, it is very straightforward and not that involved. It is simply much easier looking at the code in operation rather than posting it. I decided to Upload the DB (38K) should anyone else be interested, hope you don't mind.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32668

                      #11
                      Originally posted by msquared
                      The other option is to use two command buttons and toggle them visible/invisible as required.
                      Thanks Mary. I updated post #5 to say what I'd intended. My bad :(

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32668

                        #12
                        Originally posted by ADezii
                        Actually, it is very straightforward and not that involved. It is simply much easier looking at the code in operation rather than posting it. I decided to Upload the DB (38K) should anyone else be interested, hope you don't mind.
                        Of course not :)
                        A better idea entirely. I'll get back to you when I've had a chance to look through it properly.

                        Comment

                        Working...