Home
dbPix
Download
Order
Testimonials
Support
Tutorials
Samples
KnowledgeBase
Links
Revision History
Documentation
Search
Contact
Site Map

Graph: dbPix image storage vs OLE Embedding and Linking in Microsoft Access


Access: Linking to Existing Image Files

In some situations it may be desirable to link directly to existing external image files in their original location, rather than having the database system store copies of the images in a central location. This approach may be suitable if all of your images are already located in a permanent archive location that is accessible to all users, and therefore creating an additional copy would be an unnecessary storage overhead.

This sample can be configured to store relative paths or absolute paths. Using relative paths is recommended wherever possible, since this allows the images to be moved to a different path, drive, share or server with minimal changes to the database, however, relative paths are only workable when all of the image files are located beneath a common root location.


Download Sample   38 KB (Requires DBPix)

Download DBPix  3.7 MB ( About DBPix )


Screenshots

sample screenshot - Access: Linking to Existing Image Files
Main Form
sample screenshot - click to enlarge
Zoom Form
sample screenshot - click to enlarge
Report
sample screenshot - click to enlarge

System Requirements

Any Win32 platform (e.g. Windows 95, 98, ME, NT, 2000, XP, Vista, Server 2003 or Server 2008).
Access 2000 or later (Access 2000, XP/2002, 2003 or 2007).
DBPix 2.0

Installation

Unzip the download into a new or empty folder. Open the database and edit the module 'PathUtils', updating the value of the 'BASE_PATH' constant to use either relative or absolute paths as described in the comments.

Walkthrough

Open the form 'frmImages'. Enter a description, click 'Load' to select an image, then choose an image file using the browse dialog that appears. Note that if you have configured the sample to use relative paths the system will only allow selection of images that lie beneath the root location. Add a few new records and images and scroll though the records to view the images. Double-click one of the images to open a large view. You can also right-click the DBPix control for additional tools and info, and use <ctrl> or <shift> and click to zoom.

Open the report 'rptImages' and preview the images and descriptions entered previously.

Technical Overview

The table 'tblImages' stores the image path (whether relative or absolute) and the description.

Form 'frmImages' contains a simple text control bound to the Description field, and a DBPix control. The 'Form_Current' event is handled to display the image for the current record, by obtaining the path/filename from the table and prepending this with the root path if applicable. After checking that the file exists the image is displayed by calling the 'ImageViewFile' method of the DBPix control.

To load a new image the Load button's 'Click' event is handled, and a commn 'File Open' dialog is displayed using the boilerplate code in the module 'FileOpen'. If a file is chosen the event handler checks that the path lies beneath the root location (if defined), and if ok it strips the root path and stores the relative part in the 'PhotoPath' field. A 'Clear' button allows the link to be removed by simply clearing the 'PhotoPath' field and updating the DBPix image control.

The report 'rptImages' contains nearly identical code for displaying the image, but does so in the report's 'Detail_Print' event instead of 'Form_Current'. An important difference between the form and report is that the 'PhotoPath' field must be present on the report in a bound Text Box, otherwise the report will not fetch the value for this field. Since the path is not required to be displayed on the report the text box is configured to be non visible.


Files & Code

File / module Description  

frmImages Form code for main form. View Code
frmZoom Form code for popup Zoom form. View Code
rptImages Report code. View Code
PathUtils Common path utilities module. View Code
FileOpen Boilerplate common File Open dialog module. View Code



Revision History

Date Filename Description

16 Jun 2008   link-v4.zip   Added a popup form to zoom the current image.
16 Jun 2008   link-v3.zip   Added Report.
18 Mar 2008   link-v2.zip   Improved Access 2003 Compatability.
6 Feb 2008   link.zip   Initial Version.


000000000000000000000000000000000000000000000000000000000000000000000