Copy Files from Folder (1 Viewer)

MattBaldry

Self Taught, Learn from the Forums
Local time
Today, 20:29
Joined
Feb 5, 2019
Messages
285
Hi Forumers,

I am working on a new app at work for First Article Inspection Reports.

One of the needs of this is to have copies of the supplier CofC in the FAIR folder. I have written an import to pull the data from our Manufacturing software (CIM50) so all our quality team needs to do is type in the batch number or the components used. My code then checks the batch number with our scanned CofC folder to see if the scan exists.

The batch number will be stored in a table with the other component lines. The CofCs are all stored in the same folder.

WorksOrderIDItemIDItemStockCodeItemDescriptionItemQuantityItemUnitItemBatchNumber
NumberFPKAutoNumberPKShort TextShort TextNumberShort TextShort Text

I am after a code that will then loop through these batch numbers and move a copy of the file into the FAIR folder.

Once a FAIR report is completed I will then look at creating a zip file with all files/folders and deleting then deleting the copies, but I will look at this at a later date.

The Items will be filtered by the WorksOrderID.

Could anyone point me into the direction of how to loop through the filtered rows and move the files into the new folder?

~Matt
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:29
Joined
Jul 9, 2003
Messages
16,192
I noticed that your post has yet to receive a reply. ..

Hence I have bumped it up the list so that others may view it and you may get an answer.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:29
Joined
Feb 28, 2001
Messages
26,850
Let's do a divide-and-conquer on this one.

The easy part first even though it is the second part of your question. Read up on the FileSystemObject. (FSO for short.)


That link is the top of a documentation tree. If you look among the methods listed under FSO, one of them is MoveFile, which allows you to move a file from folder A to folder B. FSO also supports CopyFile if you want to copy the file rather than remove it from its source folder during the move. So... once you have identified something to be moved/copied, FSO will do it for you easily. Takes a couple (and ONLY a couple) of lines to set up FSO for use, then the move or copy (either one) would be a one-liner per identified file. Piece of cake.

The other part is not as clear. We start with a singular file that needs to be moved to the FAIR folder, but then you talk about a loop implying that you have multiples of something to be moved/copied. That might need a little more explanation. If I can't understand the process, I'd rather not make a wild-eyed guess and mislead you.
 

MattBaldry

Self Taught, Learn from the Forums
Local time
Today, 20:29
Joined
Feb 5, 2019
Messages
285
Let's do a divide-and-conquer on this one.

The easy part first even though it is the second part of your question. Read up on the FileSystemObject. (FSO for short.)


That link is the top of a documentation tree. If you look among the methods listed under FSO, one of them is MoveFile, which allows you to move a file from folder A to folder B. FSO also supports CopyFile if you want to copy the file rather than remove it from its source folder during the move. So... once you have identified something to be moved/copied, FSO will do it for you easily. Takes a couple (and ONLY a couple) of lines to set up FSO for use, then the move or copy (either one) would be a one-liner per identified file. Piece of cake.

The other part is not as clear. We start with a singular file that needs to be moved to the FAIR folder, but then you talk about a loop implying that you have multiples of something to be moved/copied. That might need a little more explanation. If I can't understand the process, I'd rather not make a wild-eyed guess and mislead you.
Hiya,

My apologies, Hopefully the below may help.


ItemPartDescriptionPriceQtyUnitBatch Number
1.00​
COMPONENT-1DESCRIPTION-1
1.00​
20.00​
Mtrs123456
2.00​
COMPONENT-2DESCRIPTION-2
2.00​
1.00​
Pcs456789
3.00​
COMPONENT-3DESCRIPTION-3
3.00​
1.00​
Pcs012345
As you can see, there are 3 different batch numbers, each has a scanned document in a folder with this number. I need a way of copying each of the 3 files into 1 folder for the FAIR report.

Our scanned batch PDFs are all stored in a single folder. I have a code to check the file exists, and this works fine. Now I need a code that once these are checked, they then get copied into the FAIR folder.

Each FAIR report will have different batch numbers for each component. One recent report had 42 different lines, so these had to be manually found and copied.

At the moment I have got the import from CIM50 to access working. I have the interface for the user to enter the batch number for each component line. And I can check the scanned document is in the scanned folder. It would be really good to have a code to then loop through all the component lines and copy the scanned batch document into the new folder.

Because this is currently done manually, and the people doing it are single finger typists, it can take them in excess of 2 or 3 days to move all this.

If I can automate it, this would shave 95% of their time off.

~Matt
 

Users who are viewing this thread

Top Bottom