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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get next filename still not working 1

Status
Not open for further replies.

macca007

Programmer
May 1, 2004
86
0
0
GB
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.
 
Something like this ?
If Trim(strFolderName & "") <> "" Then
Dim strFile As String
strFile = Dir(strFolderName + "\" + "*.jpg", vbNormal)
Do While strFile <> ""
Me("hospno") = strFile
strFullPath = strFolderName + "\" + strFile
DBPixMain.ImageLoadFile (strFullPath)
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
strFile = Dir
Loop
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top