Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding filename to a separate text field when batch uploading images

Status
Not open for further replies.

ncalcaterra

Programmer
Nov 11, 2004
27
US
Hi - I'm using this program DBPix and it's just great for what I need it to do. I can upload a batch of photos or a single photo, depending on my needs. My table for storing the images is pretty simple:

ItemID (autonumber)
ImgDetail (OLE Object)
DetailWidth (Number)
DetailHeight (Number)
ImgThumbnail (OLE Object)
ThumbWidth (Number)
ThumbHeight (Number)
ImgFileName (Text)

Below is the code for uploading the images (batch style). The only thing I'd like to alter about it, is to take the filename (just the filename, not the path) and add that to the "ImgFileName" field on it's own. I need to be able to use the filename for relationships down the road, so having this stored as text on its own would be extremely helpful.

Any help would be extremely appreciated!!!!

' Batch-Load button clicked: Load an entire folder of images (into new records)
Private Sub btnBatchLoad_Click()
On Error GoTo Finish

Dim strFile As String
Dim strFullPath As String
Dim strFolderName As String

' Display a 'Browse for folder' dialog - see 'BrowseForFolder' module
strFolderName = BrowseFolder("Select folder to load images from")

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

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

Finish:

End Sub
 
I was able to hear back from DBPix and the problem was resolved by taking the following action to the code I pasted above:

Replace the following line:
DBPixMain.ImageLoadFile (strFullPath)
With this:
If DBPixMain.ImageLoadFile (strFullPath) Then
[PathField] = strFile
End If

Thanks very much for your response and suggestion, Ed. I really do appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top