Solved

Find File and copy to new folder

Posted on 2008-06-19
2
613 Views
Last Modified: 2008-06-19
Access 2003 vba

What I have:

 a folder

C:Program Files\Data

I need a function from a command button:

to search for files with a like statement


I need some type of a parameter query where I put a string into:

In this case:

BR1RYK


I need the function  to look inside the folder and find all the files with this inside the file name
10_58_AM_BR1RYK_P-03272008.xls



and place it into a new folder:

C:Program Files\Data\found


Thanks
fordraiders
0
Comment
Question by:fordraiders
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 21823608



Sub xcopyFile()
Dim s, sFile, fpath, dPath
dPath = "C:Program Files\Data\found"
s = InputBox("enter string")
s = "*" & s & "*"
fpath = "C:Program Files\Data\"
sFile = Dir(fpath & s & ".xls")

While sFile <> ""
    FileCopy fpath & sFile, dPath & "\" & sFile

    sFile = Dir
Wend
End Sub
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 21823810
If you want them moved instead of copied then you might wanna add the kill statement to delete the file after the copy
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now