Avoid make table queries, they can sometimes be useful, but come with some
overhead. You can use a query as a recordset. Here is a revised version:
Public Function TransferPics()
Dim strFileName As String
Dim strSourcePath as String
Dim strTargetPath as String
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("MyQueryName")
If rst.Recordcount = 0 Then
MsgBox "No Pictures Found"
Else
strSourcePath = "C:\IdPictures\"
strTargetPath = "C:\NewIdPictures\"
With rst
.MoveLast
.MoveFirst
Do While Not .EOF
strFileName = ![PictureFieldName]
FileCopy strSourcePath & strFileName, strTargetPath &
strFileName
Loop
End With
rst.Close
Set rst = Nothing
End If
--
Dave Hargis, Microsoft Access MVP
Gary said:
Thank you for your help! I am fairly new to Access, or at least to Visual
Basic... Yes the query does filter the records. If this makes it harder, I
could just make it a make-table query, although I'd like to avoid that step
if possible.
-Gary
:
Gary, I ignored the query part. This doesn't require a query unless the
query filters records. If that is the case, let me know and we can revise.
--
Dave Hargis, Microsoft Access MVP
:
Hi, I have a query that returns results like:
Name: ID: Picture ID File Name:
Bob 1234 bobs_id_pic.jpg
Tina 5678 tinas_id_pic.jpg
...
Is there a way to use these results to (automatically) copy all the id_pics
to another folder (assuming all ID pics are in the same folder)? Thanks!