[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Copy file based on check box in MS Access Table

I need to copy files from Folder A to Folder B, but I only want to copy files based on whether or not a specific attribute exists in a table.  I have a table (Table 1) that contains two attribute fields: "File Name" and "Replace" (the "Replace" field is a Yes/No (check-box) field).  I would like to loop through the records in the table, and copy each file listed in the table, (based on on the file name), where the "Replace" attribute is checked.

I don't know if this makes any sense, or if it's even possible, but I figure that I doesn't hurt to ask.

Thank you in advance.
0
giswest
Asked:
giswest
1 Solution
 
Rey Obrero (Capricorn1)Commented:
use recordsets

dim rs as dao.recordset, strSource, strDest
strSource="c:\FolderA\"
 strDest="c:\FolderB\"
set rs=currentdb.openrecordset("select * from table1 where replace=true")

if rs.eof then exit sub

do until rs.eof
       filecopy strsource & rs![File Name], strDest & rs![File Name]

rs.movenext
loop
0
 
giswestAuthor Commented:
capricorn1,

Awsome response and solution, as usual!  I had not even considered filtering the records when defining the recordset.  I'll definitely store this one in memory banks for future reference.

Have a good weekend.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now