Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Find File and copy to new folder

Posted on 2008-06-19
2
Medium Priority
?
654 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

879 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