Log in

View Full Version : [SOLVED:] Need code to move the "first" file only in a folder to another folder.



PJCrittenden
06-25-2014, 03:55 PM
Folder A has 30 files. I need to move the first file in folder A to folder B and kill the same file in folder A.

I want to move one file at a time because a lot of processing has to go on before I move the next file.

I do not want to have to use a specific name to move it...I can do that....I just need it to take the first file every time I push a button.

I will put the code in a module and use a macro to start it.

Thanks.

jonh
06-26-2014, 06:46 AM
sub example()
file = dir("c:\source\")
do until file =""
name "c:\source\" & file as "c:\dest\" & file
call processthefile "c:\dest\" & file
file = dir
loop
end sub

PJCrittenden
06-26-2014, 08:51 AM
Didn't work for me. Got "Compile error: Variable not defined"

Also the Call processthefile "c:\dest\" & file is red so I don't know what's up with that.

I pasted your code into a module in MS Access 2007, changed the directory name both source and destination.

I'm curious since I can't get this to work, is it supposed to grab the 1st file only to move from source as I described in my original post?

Thank you for your help....

PJCrittenden
06-26-2014, 10:00 AM
Got it to work. Had to add Dim file As String. Thanks!