Hi i have this code which gets the filename and adds to the database. However the code to get the next file is:
Me("hospno") = dir
Which works but does not execute in my code. I used the
msgbox dir which shows me next file in the folder. However this is not added to my database. Could someone help me with this one.
The code is this:
Private Sub btnBatchLoad_Click()
On Error GoTo Finish
Dim strFullPath As String
Dim strFolderName As String, strFileName As String
Dim i As Integer
strFolderName = "C:\Database\Images\"
strFileName = Dir(strFolderName & "*.*", vbNormal)
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)
Me("hospno") = strFileName
Do While strFile <> ""
FileList.Add strFile
strFile = Dir
Me("hospno") = 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
What am trying to do is get the next file and add to the database field hospno.
Me("hospno") = dir
Which works but does not execute in my code. I used the
msgbox dir which shows me next file in the folder. However this is not added to my database. Could someone help me with this one.
The code is this:
Private Sub btnBatchLoad_Click()
On Error GoTo Finish
Dim strFullPath As String
Dim strFolderName As String, strFileName As String
Dim i As Integer
strFolderName = "C:\Database\Images\"
strFileName = Dir(strFolderName & "*.*", vbNormal)
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)
Me("hospno") = strFileName
Do While strFile <> ""
FileList.Add strFile
strFile = Dir
Me("hospno") = 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
What am trying to do is get the next file and add to the database field hospno.