Ok June I have been coming back to this when I have time and still can't seem to get it right. time is short, closing March 31st. So please one more time
File structure:
Documents are located in C:\CMSDocs
I want to move them to C:\ClientDocs
Table holding the document list is tblDocuments
Two fields
ClientID
DebtorID
Sub PDF()
Dim rsClients As DAO.Recordset
Dim rsDocs As DAO.Recordset
Set rsClients = CurrentDb.OpenRecordset("SELECT DISTINCT ClientID FROM tblDocuments;")
While Not rsClients.EOF
Set rsDocs = CurrentDb.OpenRecordset("SELECT ClientID, DebtorID FROM tblDocuments WHERE ClientID = " & rsClients!ClientID;") "Getting a syntax error here"
While Not rsDocs.EOF
MkDir "C:\ClientDocs\" & ClientID
FileCopy "C:\ClientDocs\" & rsDocs!DebtorID, "C:\ClientDocs\" & ClientID = "\" & rsDocs!DebtorID
rsDocs.MoveNext
Wend
rsDocs.Close
rsClients.MoveNext
Wend
End Sub