Solved

Find File and copy to new folder

Posted on 2008-06-19
2
625 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 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