For Each Record

E

Emma Hope

Hi All,

I have a continous form, which logs a list of report names and their 'new'
names.

I want to press a button which will then loop through each record and copy
the file from pathA to pathB, i can do the copy and rename bit.

For each record on formA
copy [Filename] from strPathA to strPathB
Next record
Repeat

I don't even know where to begin with the 'for each' bit, please can someone
help me....
 
K

Keith Wilby

Emma Hope said:
Hi All,

I have a continous form, which logs a list of report names and their 'new'
names.

I want to press a button which will then loop through each record and copy
the file from pathA to pathB, i can do the copy and rename bit.

For each record on formA
copy [Filename] from strPathA to strPathB
Next record
Repeat

I don't even know where to begin with the 'for each' bit, please can
someone
help me....

You could use an update query to do that but I do wonder why you'd want to
do that since you'd be duplicating data. What's your aim?

Keith.
www.keithwilby.co.uk
 
B

BruceM via AccessMonster.com

I think the OP means to move a file such as a Word document or pdf file or
some such thing from one location to another. I don't have a solution, and
I'm not sure I understand the OP's intention, but that's how I read it.

Keith said:
[quoted text clipped - 12 lines]
someone
help me....

You could use an update query to do that but I do wonder why you'd want to
do that since you'd be duplicating data. What's your aim?

Keith.
www.keithwilby.co.uk
 
K

Keith Wilby

BruceM via AccessMonster.com said:
I think the OP means to move a file such as a Word document or pdf file or
some such thing from one location to another.

ah, penny drops. Thanks Bruce. In that case I don't have a solution either.

Keith.
 
D

Dirk Goldgar

Emma Hope said:
Hi All,

I have a continous form, which logs a list of report names and their 'new'
names.

I want to press a button which will then loop through each record and copy
the file from pathA to pathB, i can do the copy and rename bit.

For each record on formA
copy [Filename] from strPathA to strPathB
Next record
Repeat

I don't even know where to begin with the 'for each' bit, please can
someone
help me....


With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF

' Copy file from one place to another. Here's possible
code:
FileCopy strPathA & "\" & !Filename, strPathB & "\" &
Filename

.MoveNext
Loop
End If
End With
 
S

Stuart McCall

Emma Hope said:
Hi All,

I have a continous form, which logs a list of report names and their 'new'
names.

I want to press a button which will then loop through each record and copy
the file from pathA to pathB, i can do the copy and rename bit.

For each record on formA
copy [Filename] from strPathA to strPathB
Next record
Repeat

I don't even know where to begin with the 'for each' bit, please can
someone
help me....

With Me.RecordsetClone
Do Until .EOF
FileCopy !PathA, strPathB
.MoveNext
Loop
End With

That means: "Using a clone of the recordset filling the continuous form,
start a loop running from the 1st record to the last (EOF - stands for End
Of File). Inside the loop, use the FileCopy statement to copy the contents
of the field PathA to the folder strPathB. Move forward 1 record (movenext)
and go round again.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top