csXImage use to generate a report with images stored 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. (It is the same demo as on the previous page.)

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

Download the demo - AccessDemo.zip (150 KB)

The Access demo provided has several images already loaded into the database. Most of these images are simple geometric shapes (squares, circles) in various colours. The 'Description' field contains an appropriate text string, e.g., "Green Square".

A query has been set up in the demo to search for images where the Description field includes a chosen text string. In the example shown here, that query finds all images which include "Red" in the description.

An Access report has then been configured to display those images. The result is as shown below:

Access report with image displayed by csXImage

The csXImage control is again used to read the image data from the database field, using the ReadBinary2 method. When used in an Access report, csXImage does not always display correctly, so the data is then transferred to a standard Access Image control, while the csXImage is kept in the background with its Visible property set to 'False'. The code needed to process the image in this way is contained in the 'Detail_Format' event procedure and is shown below:

Note: Earlier versions of csXImage had a method called ReadBinary which has been replaced by ReadBinary2. ReadBinary is still supported for compatibility but it used a redundant second parameter to identify the expected file format.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim TempVar As Variant

TempVar = ImageData
ImageBox2.ReadBinary2 TempVar
Image1.PictureData = ImageBox2.PictureData

End Sub

By modifying the query "ImageTableQuery" in the demo application, and by adding further images to the database, the results shown in the report can be modified.



This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.