copying files based on recordset (1 Viewer)

blioux

Registered User.
Local time
Today, 17:22
Joined
Sep 10, 2002
Messages
14
i'm trying to copy a group of wave files from several folders to one folder based on the results of a query. the only difference in the original paths would be based on the date they were sold and the phone number (.wav files named after the phone numbers placed in folders named for each day)

i think i'm close with what i have below, it worked with individual files but when i tryed to get it to loop through a recordset i get a type mismatch error.


this is the bad code:

Private Sub Command45_Click()
On Error GoTo Err_Command45_Click

Dim dt As String
Dim rs As ADODB.Recordset
Dim stPath As String
Dim stFile As String
Dim stPhone As String
Dim stWav As String
Dim stWUD_Date As String
Dim strSource As String
Dim strDestination As String
Dim strWUDC_Date As String

Set rs = Forms!retrieve_test_form.RecordsetClone
rs.MoveFirst
Do While Not rs.EOF
stWUD_Date = CStr(rs.Fields("write up date"))
stPath = "\\Sunserver\Suntasia\Recordings\Shift_Capital_Recordings\" & stWUD_Date & "\"
stPhone = rs.Fields("phone")
stWav = ".wav"
stFile = stPhone & stWav
strSource = stPath & stFile
strDestination = "C:\retrieve_test\" & stFile

FileCopy strSource, strDestination
rs.MoveNext
Loop

Exit_Command45_Click:
Exit Sub

Err_Command45_Click:
MsgBox Err.Description
Resume Exit_Command45_Click

End Sub


this is the good code (for single records):

Private Sub Retrieve_Recording_Click()
On Error GoTo Err_Retrieve_Recording_Click
Dim stPath As String
Dim stFile As String
Dim stPhone As String
Dim stWav As String
Dim stWUD_Date As String
Dim strSource As String
Dim strDestination As String

stWUD_Date = CStr(Me.Write_Up_Date.Value)
stPath = "\\Sunserver\Suntasia\Recordings\Shift_Capital_Recordings\" & stWUD_Date & "\"
stPhone = Me.Phone.Value
stWav = ".wav"
stFile = stPhone & stWav

strSource = stPath & stFile
strDestination = "C:\retrieve_test\" & stFile

FileCopy strSource, strDestination

Exit_Retrieve_Recording_Click:
Exit Sub

Err_Retrieve_Recording_Click:
MsgBox Err.Description
Resume Exit_Retrieve_Recording_Click

End Sub

any help would be greatly appriciated
 

Tim K.

Registered User.
Local time
Today, 22:22
Joined
Aug 1, 2002
Messages
242
Since ADO does not have RecordsetClone, so have to change

Dim rs As ADODB.Recordset

to

Dim rs As Object
 

blioux

Registered User.
Local time
Today, 17:22
Joined
Sep 10, 2002
Messages
14
you rock!
thanx!!
 

Users who are viewing this thread

Top Bottom