Solved

Copy file based on check box in MS Access Table

Posted on 2012-04-13
2
207 Views
Last Modified: 2012-04-13
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
Comment
Question by:giswest
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 37843169
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
 

Author Closing Comment

by:giswest
ID: 37843551
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

832 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