Ok, I need help. First I am running Access 2000 on a Windows 7 computer, don't laugh, I know. I have a database called testing containing a table called Table1. The table consists of a single field, FileName. I am trying to code a module to look in a particular folder and copy all the files, the names of which appear in the table without suffix, from a source folder to a destination folder. Here is what I have so far:
Public Function CopyCalls()
Dim testing As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strSource As String
Dim strDestination As String
Dim strCallPath As String
Dim strCallDest As String
Dim strCallName As String
Set testing = CurrentDb
strCallPath = "C:\Users\Richard"
strCallDest = "C:\Users\Richard\Temp\"
strSQL = "SELECT * FROM Table1;"
Set rs = testing.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveLast
rs.MoveFirst
Do
strCallName = rs!FileName
strSource = strCallPath & "\" & strCallName
strDestination = strCallDest & strCallName
FileCopy strSource, strDestination
rs.MoveNext
Loop Until rs.EOF
Set rs = Nothing
End Function
It gives an error on the line "FileCopy strSource, strDestination" that the file is not found. But the file Note, the file name in the table, is present in the source folder.
This is just an attempt to get the code working, I will be changing the necessary components to the proper table, and source and destination folders.
Thanks in advance.
Public Function CopyCalls()
Dim testing As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strSource As String
Dim strDestination As String
Dim strCallPath As String
Dim strCallDest As String
Dim strCallName As String
Set testing = CurrentDb
strCallPath = "C:\Users\Richard"
strCallDest = "C:\Users\Richard\Temp\"
strSQL = "SELECT * FROM Table1;"
Set rs = testing.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveLast
rs.MoveFirst
Do
strCallName = rs!FileName
strSource = strCallPath & "\" & strCallName
strDestination = strCallDest & strCallName
FileCopy strSource, strDestination
rs.MoveNext
Loop Until rs.EOF
Set rs = Nothing
End Function
It gives an error on the line "FileCopy strSource, strDestination" that the file is not found. But the file Note, the file name in the table, is present in the source folder.
This is just an attempt to get the code working, I will be changing the necessary components to the proper table, and source and destination folders.
Thanks in advance.