Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-access > #9973 > unrolled thread
| Started by | "PR" <randlov_(remove this)@post9.tele.dk> |
|---|---|
| First post | 2014-10-03 21:44 +0200 |
| Last post | 2014-10-04 17:38 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.databases.ms-access
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
| From | "PR" <randlov_(remove this)@post9.tele.dk> |
|---|---|
| Date | 2014-10-03 21:44 +0200 |
| Subject | Copying files with VB statement |
| Message-ID | <542efc65$0$23229$edfadb0f@dtext01.news.tele.dk> |
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.
[toc] | [next] | [standalone]
| From | Neil <xxx@gmail.com> |
|---|---|
| Date | 2014-10-03 16:42 -0500 |
| Message-ID | <542F184B.9010509@gmail.com> |
| In reply to | #9973 |
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
[toc] | [prev] | [next] | [standalone]
| From | "PR" <randlov_(remove this)@post9.tele.dk> |
|---|---|
| Date | 2014-10-04 17:38 +0200 |
| Message-ID | <5430142b$0$23227$edfadb0f@dtext01.news.tele.dk> |
| In reply to | #9974 |
"Neil" skrev i meddelelsen news:542F184B.9010509@gmail.com...
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
Thank you very much, Neil
It looks much like what I need.
Best regards
Peter R.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.databases.ms-access
csiph-web