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


Batch-loading & processing images with Microsoft Access

    
DBPix Image Control 
DBPix Developers Kit
Download V2.0
For Windows XP, 2000,
NT, ME, 98 & 95


Buy Now!

DBPix Resources
Samples
Support
About DBPix


Check the Support pages for samples using this and similar techniques.

This code Loads all the image files in a particular directory into a database. The images would be processed according to the DBPix control's settings (eg any resampling, compression).

This code could be extended to automatically create thumbnails or work with external files as required. You could move the processed original files to an "archiving" directory, possibly on CD, move any files which failed to load to an "Errors" folder etc.

Private Sub BatchLoad_Click()
    On Error GoTo Finish
    Dim szDir As String
    Dim szSearchSpec As String
    Dim szFile As String
    Dim szFullPath As String

    szDir = "C:\images\    'The source directory for our images
    szSearchSpec = szDir + "*.jpg"    'Filespec for directory listing

    szFile = Dir(szSearchSpec, vbNormal)    'Generate a list of matching files
    While (Not StrComp(szFile,     ""))
        If Len(szFile) > 1 Then
            szFullPath = szDir + szFile
            DBPixCtl.ImageLoadFile (szFullPath)    'Load the file
            DoCmd.GoToRecord , , acNewRec     'Move the recordset cursor to the next image
        End If
        szFile = Dir    'Get the next filename from the directory listing
    Wend
    Finish:
End Sub