Store pictures as link in db

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi

I'd like to store more than 1000 pictures as link in a microsoft access
recordset. I know how to do that manually with a form, but how to do it with
a loop command?

Many thanks in advance.

Tom
 
Presumably this is a hyperlink field?

You could OpenRecord() on this table, and either Edit or AddNew, with
Update. Make sure you include both the display and address in the hyperlink
field and the two hashes. For example, if the file name is in the string
variable strFile:
rs!MyHyperlink = strFile & "#" & strFile & "#"

More information on hyperlink fields:
http://allenbrowne.com/casu-09.html
 
It rather depends on some more detail about your requirements. Are you trying to match files to existing
records ? or just add a new record for each file found ? something else ?

Here's some code from our 'batchload' sample that you may be able to use as a starting point:

strCaption = "Select folder to load images from"
strFolderName = BrowseFolder(strCaption)

If Not IsEmpty(strFolderName) Then
strSearchSpec = strFolderName + "\" + "*.jpg"
strFile = Dir(strSearchSpec, vbNormal)

While (Not StrComp(strFile, ""))
If Len(strFile) > 1 Then
strFullPath = strFolderName + "\" + strFile
DoCmd.GoToRecord , , acNewRec
ActiveXCtl0.ImageLoadFile (strFullPath)
End If
strFile = Dir
Wend
End If

Notes:

* BrowseFolder uses the sample code by Terry Kreft.
* Replace the 'ActiveXCtl0.ImageLoadFile(strFullPath)' with your own code to store the path, copy the image
or whatever.
* The sample itself is available for download from our website (see sig below), but note that as-is it
uses our own image control, resamples the images and stores them in the table, rather than storing the
path.
 
Back
Top