If you are into the Microsoft Access development and you wanted to beautify your application with custom images it's almost certain that sometime you have encountered the dreaded :
Over time Access has “evolved” to be more forgiving on this subject by allowing Controls to be more versatile about accepting different format images than BMP (.dib) but this is not the case…it always comes a case that you need to assign on the fly some images to some controls to find out is impossible….well till now
I present the Dynamic Image Handler…a small demo Microsoft Access Application that will take care of this…
Just pick your .jpg …store it and use it, just let the code make the conversion from jpg.
So no more hunting down the paths where your images are stored…no more dreaded messages that the image you have stored in the database is NOT compliant…just plain simple…pick your images…store them in your application with the known tiny size of .jpgs…most images presented in the application is just 2-4 kb size and just assign them to your controls…on the fly…no temp files... no extra controls to store the PictureData…no nothing
For start just open the Application :
And get to the form that shows 4 major controls (A Command Button, An Image, A Tab Control with 2 pages and a Toggle button)
On each case, you have a small button to pick your image…select it and let it show on the matching control.
If you have assigned images to all the controls you can click the Save Button
And review what you have already inserted
You want to insert images for your controls…as I did for everything that you see in this application.
You will be presented with this simple form
Nothing special …just type the Name of the Image and hit the Insert button…nothing more …nothing else.
Some small note here: The Check for OnlyForBMP is to store images for the Ribbon Controls…because I want to have them transparent I have to store them as BMPs…maybe in the future I could modify the code to take care of that but because its just for the Ribbon Controls and the sizes are small is wiser and easier to store them as BMP and get over it…as for the transparency if there is interest I will make a small article on this if there is interest.
The other two CheckBoxes just fill the empty space of not perfect images (size not multiple of 4) to instead of the default white to black or control (I tried to trick the Ribbon Controls but transparency is always nicer)
The application is completely unlocked so it's easy to check the underlying code and get a look at how the processing takes place.
I think the potential of this code is far greater…starting with the fact that you can store just about every image (jpg) taking advantage of its small size…and also because the resulting PictureData is just a Byte Array …you can dump the ImageList ActiveX Control and just store your images on a simple Collection.
Of course the more you use it the more uses you will find…
The application is here: DynamicImageHandler.accdb
It has been developed in Access 2019 x86 (32bit) and it should run on All 32bit Access from 2010 and after (on 2007 there is some issue on rendering the Page Control...probably there is a limitation because when I tried manually to assign an image it got distorted)
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.