Access – Color Picker

HTML Color Picker
In my first part of this exploration of how to enable users to make color selections within a database, I demonstrated how we can use the built-in ChooseColor API dialog. This time round, I wanted to explore using an HTML color picker. Why, you might ask, well, I wanted to see what could be used that didn’t require APIs. Furthermore, I have seen many very good JavaScript color picker and simply wanted to have some fun!

Beside not needing to mess around with APIs, conditional compilation directives, … another advantage of this approach is the simple fact that since this is built upon plain HTML, JavaScript & CSS, we can make any changes we wish to the appearance of the dialog, unlike when using the built-in Windows ChooseColor API dialog approach.
 

The Overall Concept

Like many of my previous posts on the subject, in the past few years, I have learnt that the WebBrowser control enables us to GREATLY extend Access’ capabilities and add features that wouldn’t be possible otherwise. Add to that the fact that there is a tremendous amount of free, open-sources set of resources that we can drop into place and get operational very quickly saving us the time and energies to develop in the first place.

So the idea is to use the WebBrowser control in Access to load HTML components and return the results, in this case a color code.

There are a great many color picker libraries we could use, but for this demo I selected the FlexiColorPicker by David Durman.

So I built a form around this library, then open it in dialog mode and return the user’s selection to the calling form element. I’ve also demonstrated how with 2 lines of code a simple wrapper function can be created thus allowing one to call if with a single line of code if wished.

The only thing left is for you to take the Demo for a tour!

Disclaimer/Notes:

If you do not have Microsoft Access, simply download and install the freely available runtime version (this permits running MS Access databases, but not modifying their design):

Microsoft Access 2010 Runtime
Microsoft Access 2013 Runtime
Microsoft Access 2016 Runtime
Microsoft 365 Access Runtime

All code samples, download samples, links, ... on this site are provided 'AS IS'.

In no event will Devhut.net or CARDA Consultants Inc. be liable to the client/end-user or any third party for any damages, including any lost profits, lost savings or other incidental, consequential or special damages arising out of the operation of or inability to operate the software which CARDA Consultants Inc. has provided, even if CARDA Consultants Inc. has been advised of the possibility of such damages.

Download a Demo Database

Feel free to download a 100% unlocked demo copy by using the link provided below:

Download “Access - HTML Color Picker” Color_Picker_HTML_V1.000.zip – Downloaded 7947 times – 37.94 KB  

Looking For An Alternative

If you want another possible solution, be sure to check out:

 

Page History

Date Summary of Changes
2020-12-13 Initial Public Release
2023-02-07 Added the Looking For An Alternative section

4 responses on “Access – Color Picker

  1. James Reed

    I downloaded your HTML Color Picker and was wondering how I could use it to actually change the color of a New Form. The colors that you get are so much better than the normal colors.

    Jim

    1. Daniel Pineault Post author

      You just have to capture the selected color and then apply it to the selected form/objects… If you review the ColorPickerDemo form in the downloadable demo database it shows you exactly how you can do this.

  2. Greg Sevior

    Hi Daniel
    Thank you for an awesome color selection option.
    The only issue I found was if you do not select a color, and then click the ‘Use This Color’ button you receive an error. (err 9 – out of range). You might want to throw in an error handler to escape err = 9.

    Cheers

  3. Greg Sevior

    Hi Daniel

    Is there a method where it is possible to pass the color picker and initial color to display when it opens, and to perhaps display the last 5 to 10 color selections made. Very handy where you want to slightly change an existing background shade, or have multiple fields/controls you want to make the same color.

    Cheers