INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Loop for Importing and Moving Files

Loop for Importing and Moving Files

(OP)
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!!

RE: Loop for Importing and Moving Files

This looks like Access VBA rather than VB6. You may do better in forum705: Microsoft: Access Modules (VBA Coding) 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: How to get the best answers first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints

RE: Loop for Importing and Moving Files

(OP)
Ok-thanks for the clarification I will try there.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close