How to move a File using VBA

I have code (using VBA Access 2010) that checks to see if a File exists (it works). If the File exists I need to rename it and MOVE it to a local location.  

In the code below the NEW file name is newpriceMonthYear where vMonthYear (for October) would be 102017.txt and the new file name will be "newprice102017.txt".  Creating vMonthYear  works. vMonthYear is Dim'd as a STRING  The code executes with no errors but the File is NOT moved

CODE:
Dim FSO As FileSystemObject
FileToMove = "C:\RDC-POS\OLCC Downloads\newprice.txt"
DestPath = "C:\RDC-POS\OLCC Past Downloads\newprice" & vMonthYear
FSO.MoveFile FileToMove, DestPath
jurictaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Try  (Note: Not FSO)

Name FileToMove As DestPath
0
Bill PrewIT / Software Engineering ConsultantCommented:
You seem to be missing:

Set FSO = CreateObject("Scripting.FileSystemObject")

Open in new window


»bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jessica KCommented:
Hello Juricta,

Try the following code:

Using a VBA Code Move a single file from one location to another in MS Access
If it didn't resolve your issue, please let us know. We will surely help you with another solution.

Regards,
Jessica
0
jurictaAuthor Commented:
Bill was the "spot on" answer.  adding his line to my code makes it work perfectly.  Thanks to all who added to my question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.