Hi all,
I have this code which looks into the path of the folder of images and loads the images (one big image and the other a thumbnail).
My question is, How do i get the filename from the file? (i have higlighted the code in red where i would like to store the filename)
The code is this
' retrieve the path where images are stored - in this case the it's the path of the .mdb file itself
Dim Path As String
Dim FileName As String
Path = GetImgFolder
DBPixThumb.Image = Null
DBPixMain.Image = Null
FileName = Me!ItemId & ".jpg"
If Dir(Path & FileName) <> vbNullString Then
DBPixMain.ImageViewFile (Path & FileName)
End If
FileName = "t" & Me!ItemId & ".jpg"
If Dir(Path & FileName) <> vbNullString Then
DBPixThumb.ImageViewFile (Path & FileName)
End If
End Sub
Private Sub DBPixMain_ImageModified()
Dim FileName As String
DBPixThumb.Image = Null ' Clear the thumbnail
Me("ThumbWidth") = 0 ' Reset image info (and force update of Id if new record)
Me("ThumbHeight") = 0
Me("DetailWidth") = 0
Me("DetailHeight") = 0
'
If DBPixMain.ImageBytes > 0 Then
' Update the thumbnail
DBPixThumb.ImageLoadBlob (DBPixMain.Image) ' Copy/Paste is faster, if you don't mind overwriting the clipboard
' DBPixMain.ImageCopy
' DBPixThumb.ImagePaste
''
If DBPixMain.ImageSaveFile(GetImgFolder & Me!ItemId & ".jpg") Then
Me("hospno") = FileName
' Me("DetailWidth") = DBPixMain.ImageWidth ' Uppdate Detail image info
' Me("DetailHeight") = DBPixMain.ImageHeight
'
If DBPixThumb.ImageSaveFile(GetImgFolder & "t" & Me!ItemId & ".jpg") Then
' Me("ThumbWidth") = DBPixThumb.ImageWidth ' Update the thumbnail image info
' Me("ThumbHeight") = DBPixThumb.ImageHeight
End If
End If
End If
End Sub
Private Sub btnBatchLoad_Click()
On Error GoTo Finish
Dim strFullPath As String
Dim strFolderName As String
Dim i As Integer
' Display a 'Browse for folder' dialog - see 'BrowseForFolder' module
' strFolderName = BrowseFolder("Select folder to load images from")
strFolderName = "C:\Database\Images\"
If Not IsEmpty(strFolderName) And Not strFolderName = "" Then
Dim FileList As New Collection ' List of files in folder (to prevent potential recursive calls to Dir)
Dim strFile As String
strFile = Dir(strFolderName + "\" + "*.jpg", vbNormal)
Do While strFile <> ""
FileList.Add strFile
strFile = Dir
Loop
For i = 1 To FileList.Count ' Try to load each file - DBPixMain_ImageModified does the work of updating
strFile = FileList(i)
If Len(strFile) > 1 Then
strFullPath = strFolderName + "\" + strFile
DBPixMain.ImageLoadFile (strFullPath)
DoCmd.GoToRecord , , acNewRec
End If
Next i
End If
Finish:
End Sub
many thanks
I have this code which looks into the path of the folder of images and loads the images (one big image and the other a thumbnail).
My question is, How do i get the filename from the file? (i have higlighted the code in red where i would like to store the filename)
The code is this
' retrieve the path where images are stored - in this case the it's the path of the .mdb file itself
Dim Path As String
Dim FileName As String
Path = GetImgFolder
DBPixThumb.Image = Null
DBPixMain.Image = Null
FileName = Me!ItemId & ".jpg"
If Dir(Path & FileName) <> vbNullString Then
DBPixMain.ImageViewFile (Path & FileName)
End If
FileName = "t" & Me!ItemId & ".jpg"
If Dir(Path & FileName) <> vbNullString Then
DBPixThumb.ImageViewFile (Path & FileName)
End If
End Sub
Private Sub DBPixMain_ImageModified()
Dim FileName As String
DBPixThumb.Image = Null ' Clear the thumbnail
Me("ThumbWidth") = 0 ' Reset image info (and force update of Id if new record)
Me("ThumbHeight") = 0
Me("DetailWidth") = 0
Me("DetailHeight") = 0
'
If DBPixMain.ImageBytes > 0 Then
' Update the thumbnail
DBPixThumb.ImageLoadBlob (DBPixMain.Image) ' Copy/Paste is faster, if you don't mind overwriting the clipboard
' DBPixMain.ImageCopy
' DBPixThumb.ImagePaste
''
If DBPixMain.ImageSaveFile(GetImgFolder & Me!ItemId & ".jpg") Then
Me("hospno") = FileName
' Me("DetailWidth") = DBPixMain.ImageWidth ' Uppdate Detail image info
' Me("DetailHeight") = DBPixMain.ImageHeight
'
If DBPixThumb.ImageSaveFile(GetImgFolder & "t" & Me!ItemId & ".jpg") Then
' Me("ThumbWidth") = DBPixThumb.ImageWidth ' Update the thumbnail image info
' Me("ThumbHeight") = DBPixThumb.ImageHeight
End If
End If
End If
End Sub
Private Sub btnBatchLoad_Click()
On Error GoTo Finish
Dim strFullPath As String
Dim strFolderName As String
Dim i As Integer
' Display a 'Browse for folder' dialog - see 'BrowseForFolder' module
' strFolderName = BrowseFolder("Select folder to load images from")
strFolderName = "C:\Database\Images\"
If Not IsEmpty(strFolderName) And Not strFolderName = "" Then
Dim FileList As New Collection ' List of files in folder (to prevent potential recursive calls to Dir)
Dim strFile As String
strFile = Dir(strFolderName + "\" + "*.jpg", vbNormal)
Do While strFile <> ""
FileList.Add strFile
strFile = Dir
Loop
For i = 1 To FileList.Count ' Try to load each file - DBPixMain_ImageModified does the work of updating
strFile = FileList(i)
If Len(strFile) > 1 Then
strFullPath = strFolderName + "\" + strFile
DBPixMain.ImageLoadFile (strFullPath)
DoCmd.GoToRecord , , acNewRec
End If
Next i
End If
Finish:
End Sub
many thanks