Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #9974

Re: Copying files with VB statement

From Neil <xxx@gmail.com>
Newsgroups comp.databases.ms-access
Subject Re: Copying files with VB statement
Date 2014-10-03 16:42 -0500
Organization A noiseless patient Spider
Message-ID <542F184B.9010509@gmail.com> (permalink)
References <542efc65$0$23229$edfadb0f@dtext01.news.tele.dk>

Show all headers | View raw


On 10/3/2014 2:44 PM, PR wrote:
> I have a database with more than 20000 records each representing a
> jpg-file (vintage Danish stereoscopic cards).
> Each record has a number of the format XY1234 and the associated file
> has the name XY1234.jpg placed in a directory …\XY\XY1234.jpg.
> When running a query e.g. pictures from “Greenland” a new table with 300
> records are generated.
> I want to take the filenames from this query and copy the files to a new
> (temporary) directory, so I can burn a CD with the files.
> Is this possible, and how would a VB statement look making the command?:
> “Copy all records from table(query “Greenland”) and paste to directory
> ….\new”
> Any suggestions?
> Peter R.

Function CopyJPGs

Dim rs as recordset
dim lng as long

Const SourceDirectory = "C:\XY\"
Const TargetDirectory = "C:\Temp\"

set rs = currentdb.openrecordset("Greenland", dbopensnapshot)

do until rs.eof
	'This assumes that the field containing the number is called
	'RecNo. Modify to use the actual field name.
	FileCopy SourceDirectory & rs!RecNo & ".jpg", _
                  TargetDirectory & rs!RecNo & ".jpg"
	lng = lng + 1
	rs.movenext
loop

MsgBox lng & " files copied to " & TargetDirectory & ".", vbInformation

End Function

Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Copying files with VB statement "PR" <randlov_(remove this)@post9.tele.dk> - 2014-10-03 21:44 +0200
  Re: Copying files with VB statement Neil <xxx@gmail.com> - 2014-10-03 16:42 -0500
    Re: Copying files with VB statement "PR" <randlov_(remove this)@post9.tele.dk> - 2014-10-04 17:38 +0200

csiph-web