A
Ant S
I am trying to develop a small Access application for a local camera club I
am a member of. Being a novice I am struggling a bit with the code if
anyone can point me in the right direction?
The idea of the application is that you batch load all the jpg images from a
folder into a database table then view and score the images via a side show
form.
I have a form that uses a DBPix 2.02 ActiveX picture control to display the
images, I have added a control button to batch load all the images (working
fine) but I would also like to add the file name into a text field
"tbl_FileName" on the same form. I don't know where or what to incorporate
that will place the filename into a text field.
This bit is working fine and is used to batch lode the images into the
BDPix202 image control.
' Batch-Load button clicked: Load an entire folder of images (into new
records)
Private Sub Cmd_LoadBatch_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
DBPix202.ImageLoadFile (strFullPath)
End If
strFile = Dir
Wend
End If
Finish:
End Sub
The code below, I found to get the file name but I can't get to work. I am
trying to (at the same time as above) place the file name into the
tbl_FileName field. I don't know where to put it or how to call it?
Function GetFilenameFromPath(ByVal strPath As String) As String
' Returns the rightmost characters of a string upto but not including the
rightmost '\'
' e.g. 'c:\My Docs\PhotoName.Jpg' returns PhotoName.Jpg'
If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
GetFilenameFromPath = GetFilenameFromPath(Left$(strPath,
Len(strPath) - 1)) + Right$(strPath, 1)
End If
End Function
Any help much appreciated. Thanks
am a member of. Being a novice I am struggling a bit with the code if
anyone can point me in the right direction?
The idea of the application is that you batch load all the jpg images from a
folder into a database table then view and score the images via a side show
form.
I have a form that uses a DBPix 2.02 ActiveX picture control to display the
images, I have added a control button to batch load all the images (working
fine) but I would also like to add the file name into a text field
"tbl_FileName" on the same form. I don't know where or what to incorporate
that will place the filename into a text field.
This bit is working fine and is used to batch lode the images into the
BDPix202 image control.
' Batch-Load button clicked: Load an entire folder of images (into new
records)
Private Sub Cmd_LoadBatch_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
DBPix202.ImageLoadFile (strFullPath)
End If
strFile = Dir
Wend
End If
Finish:
End Sub
The code below, I found to get the file name but I can't get to work. I am
trying to (at the same time as above) place the file name into the
tbl_FileName field. I don't know where to put it or how to call it?
Function GetFilenameFromPath(ByVal strPath As String) As String
' Returns the rightmost characters of a string upto but not including the
rightmost '\'
' e.g. 'c:\My Docs\PhotoName.Jpg' returns PhotoName.Jpg'
If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
GetFilenameFromPath = GetFilenameFromPath(Left$(strPath,
Len(strPath) - 1)) + Right$(strPath, 1)
End If
End Function
Any help much appreciated. Thanks