Solved

Find File and copy to new folder

Posted on 2008-06-19
2
646 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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