How to change an image on a form programatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #16
    Here is a Demo that I actually created for another User illustrating many aspects of working with BLOBs. The original Code is by Alan Warren to which I made some modifications. In the Demo you can write Images to an OLE Object Field, display a BLOB Image, retrieve Images to a Temporary Folder, display File Properties of a stored Image, Edit a BLOB Image, etc. Hopefully, you will find it somewhat useful.
    Attached Files

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #17
      As an additional note, I tested the Demo to see if it will work with *.png Files, and it does.

      Comment

      • Petrol
        New Member
        • Oct 2016
        • 248

        #18
        Well they say you live and learn, and I'm certainly learning. The BLOBs demo looks very interesting, and I'll try to study it in depth.

        Comment

        • Petrol
          New Member
          • Oct 2016
          • 248

          #19
          Well surprisingly, it turns out that all I had to do was put each of the .png images on a form somewhere (this was the clue I got from ADezii's suggestion -thanks so much!), and then set the picture property of the logo image to the name of the desired image:
          Code:
          Me![ImgLogo].Picture = conDept
          Me.Refresh
          But then I was able to ignore the form and never reference it ... in fact, I even deleted it and the thing still works. The DB engine must have hidden the images away somewhere where it could retrieve them by name on request.
          Thanks again.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32634

            #20
            Nice work Petrol. I love your thinking. However ...

            While this all works very nicely, there are times when a database gets corrupted beyond repair, that you may want to recreate the database from scratch and import across the various objects from the original that are still uncorrupted. While you can also do this with an older, saved, version if you have one, it's more common to start from scratch. If you were to do this without the original Form that has the Image controls on then you would be likely to come unstuck.

            I suggest you would be better served by keeping that Form around but with a name or comment value to indicate why.

            Comment

            • Petrol
              New Member
              • Oct 2016
              • 248

              #21
              Good point, though I shudder at the thought; however, I suspect that it was the act of placing the images on the form, rather than the existence of the form itself, that caused Access to hide copies down in its vault somewhere. I still have the original .png's from which I created the form, and they are in a file outside the DB which could get corrupted, so that's the safer option, n'est-ce pas?

              Comment

              • Petrol
                New Member
                • Oct 2016
                • 248

                #22
                Incidentally, I received an email notification of NeoPa's last post - the first one I have received for this string - even though it's addressed to an email address I don't have! In fact, it's at least a year since I had received a system-generated email from Bytes. I know this isn't a forum about emails, but there's obviously just as much I don't understand about emails as about Access LOL.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32634

                  #23
                  Interesting. I suspect the owner's been tweaking things again. I too have started receiving emails recently. I suppose we can also revisit our settings any time so go there if you're unhappy with how things are now.

                  As for the images being stored, I expect that would also happen automatically when you import the form so there is sense in keeping it. Obviously you can work with just the files in the background if you're confident that when the time comes that you need to do this you will remember all the details of this situation and not end up scratching your head wondering why these images, that used to work fine, suddenly aren't working in your new imported database.

                  Comment

                  • Petrol
                    New Member
                    • Oct 2016
                    • 248

                    #24
                    True. As always, the key is documentation.
                    Anyway, it's all working now, so thanks to you and especially ADezii for all the help.

                    Comment

                    Working...