Demo of csXImage use to store images in an Access database

To run this demo you need the csXImage trial ActiveX control installed on your system as well as MS Access. The trial control and the example database file are available below:

Download the trial csXImage control - csXImageTrial.exe (3 MB)

Download the demo - AccessDemo.zip (70 KB)

csXImage includes two methods, ReadBinary2 and WriteBinary, which can be used to store and retrieve images as a sequence of bytes. This sequence will depend on the file format that is chosen, e.g., BMP, JPEG etc. Any of the file formats supported by csXImage can be used.

In an Access database, the data type of a field can be set to "OLE Object". This data type can be used to store any kind of data, and when used with ReadBinary2 and WriteBinary, it will store images.

The demo Access database includes a form called 'ImageForm'. This form allows a user to step through the images contained in the database. A screenshot of the form is shown below.

csXImage demo for MS Access storing image in a BLOB field

This form includes several command buttons, each of which runs VBA code.

The 'Load File' button displays a dialogue allowing the user to browse for an image file to open. Any image file in a format supported by csXImage can be loaded onto the form.

After an image is loaded from file, the 'Store to DB' button stores the image into the current database record. The WriteBinary method is used to do this.

Two command buttons are also provided to allow the brightness of the image to be adjusted up or down, before storing to the database. This is an example of how the many functions available in csXImage can be incorporated into an Access application.

Next...