A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Use query results to copy files?



 
 
Thread Tools Display Modes
  #11  
Old December 18th, 2007, 12:07 AM posted to microsoft.public.access.queries
Gary
external usenet poster
 
Posts: 790
Default Use query results to copy files?

Great, it's working perfectly! Thank you so much for your help!

-Gary

"Klatuu" wrote:

Sorry about that, I left that line out.

As to the parameter prompt, I would suggest you add an unbound control on
your form to put in the value you want to filter on and refer to it in your
query:

WHERE ID = Forms!MyForm!MyControl

of course, substitute real names.
--
Dave Hargis, Microsoft Access MVP


"Gary" wrote:

I fixed issue number 2 by adding "rst.MoveNext" into the loop.

-Gary


"Gary" wrote:

Sweet! It's almost working, just two problems (I think):

1) The line:
Set rst = CurrentDb.OpenRecordset("test_GET_PICTURES")
Is telling me "too few parameters, Expected 1.". My query uses a
message-input box to filter results, i.e. the user enters "3", and my query
will find all ID#'s starting with "3". (Again. if absolutely necessary I
could use a make-table query)

2) In the loop the strFIleName is always the first one (not moving down the
rows).

Thank you SO much for all your help!

-Gary


"Klatuu" wrote:

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" wrote:

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

"Klatuu" wrote:

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


"Gary" wrote:

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!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.