Solved

Copy file based on check box in MS Access Table

Posted on 2012-04-13
2
205 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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now