For Each Record

  • Thread starter Thread starter Emma Hope
  • Start date Start date
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....
 
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
 
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.
 
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
 
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
 
Back
Top