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

Loop for Importing and Moving Files

Status
Not open for further replies.

Bonediggler1

Technical User
Joined
Jul 2, 2008
Messages
156
Location
US
Hi,

I am writing a simple program that should loop through the files in a folder, import them and then move them to another folder.

I can get the import loop but do not quite know how to fit in the move part. Here's what I have so far...the code throws an error at the .foundfiles(i).move part.

Sub Blah_Import_and_Move()


'Determine folder and file to import
Dim strFileSource As String
Dim strFileName As String
strFileSource = "C:\Blah1\Blah2\Blah3\"
strFileName = "Blah *.*"

'Determine folder where to move files
Dim strMoveFolder As String
strMoveFolder = "c:\Blah4\Blah5\Blah6\"

'Import files and move to different folder after importing
Dim fs As Object
Set fs = Application.FileSearch
With fs
.lookin = strFileSource
.filename = "*.*"
If .Execute() > 0 Then
For i = 1 To .foundfiles.Count
DoCmd.TransferText acImportFixed, "Blah_Specs", "tblBlah_Raw", .foundfiles(1), False
.foundfiles(i).Move strMoveFolder
Next i
Else
GoTo ErrorHandler
End If
End With

End Sub


Thank you!!
 
This looks like Access VBA rather than VB6. You may do better in forum705 or one of the other Access specialist forums on the site. Do a forum search (top of page) for 'Access' to get the full list

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Ok-thanks for the clarification I will try there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top