Hello,
I was wondering if someone could help me... I'm trying to loop through files within a directory, but my code doesn't seem to move past the first file. I've read that to move to a next file you could just input "myfile = dir". It doesn't seem to work here. I've pasted the code below, I'd appreciate if someone could have a look at it.
Thanks
Chris
Set db = CurrentDb()
myfile = Dir("C:\IN\*.*")
Do Until myfile = ""
If myfile = "" Then
MsgBox ("complete!")
Else
i = 0
fileinarr(i) = myfile
Open fileinarr(i) For Input As #1
Line Input #1, input_data
input_data = Replace(input_data, Chr(10), Chr(13))
fileout = Dir("C:\Out\" & i)
Open fileout For Output As #2
Print #2, input_data
Close #1
Close #2
DoCmd.RunSQL ("insert into filenamenew values ('" & i & "')")
i = i + 1
End If
myfile = Dir
Loop
I was wondering if someone could help me... I'm trying to loop through files within a directory, but my code doesn't seem to move past the first file. I've read that to move to a next file you could just input "myfile = dir". It doesn't seem to work here. I've pasted the code below, I'd appreciate if someone could have a look at it.
Thanks
Chris
Set db = CurrentDb()
myfile = Dir("C:\IN\*.*")
Do Until myfile = ""
If myfile = "" Then
MsgBox ("complete!")
Else
i = 0
fileinarr(i) = myfile
Open fileinarr(i) For Input As #1
Line Input #1, input_data
input_data = Replace(input_data, Chr(10), Chr(13))
fileout = Dir("C:\Out\" & i)
Open fileout For Output As #2
Print #2, input_data
Close #1
Close #2
DoCmd.RunSQL ("insert into filenamenew values ('" & i & "')")
i = i + 1
End If
myfile = Dir
Loop