Solved

Find File and copy to new folder

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

758 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

21 Experts available now in Live!

Get 1:1 Help Now