Hi all,
I'm having problems with the kill comand.
Basically wanting VB to provide an archive function for a folder when some on a access DB says the records is closed. My basic code is below.
I keep on getting file not found error at the kill comand. Can anyone explain what I'm doing wrong?
the DIm ID is broughtr over from a previous form.
Private Sub Command0_Click()
Dim FSO As Object
Dim ID As String
Dim FromPath As String
Dim ToPath As String
Dim K1 As String
FromPath = "C:\test\open\" & ID '<< Change
ToPath = "C:\test\closed\" & ID '<< Change
K1 = "C:\test\open\" & ID & "*.*"
If Right(FromPath, 1) = "\" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If
If Right(ToPath, 1) = "\" Then
ToPath = Left(ToPath, Len(ToPath) - 1)
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
Kill (K1)
RmDir (FromPath)
MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath
End Sub
I'm having problems with the kill comand.
Basically wanting VB to provide an archive function for a folder when some on a access DB says the records is closed. My basic code is below.
I keep on getting file not found error at the kill comand. Can anyone explain what I'm doing wrong?
the DIm ID is broughtr over from a previous form.
Private Sub Command0_Click()
Dim FSO As Object
Dim ID As String
Dim FromPath As String
Dim ToPath As String
Dim K1 As String
FromPath = "C:\test\open\" & ID '<< Change
ToPath = "C:\test\closed\" & ID '<< Change
K1 = "C:\test\open\" & ID & "*.*"
If Right(FromPath, 1) = "\" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If
If Right(ToPath, 1) = "\" Then
ToPath = Left(ToPath, Len(ToPath) - 1)
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
Kill (K1)
RmDir (FromPath)
MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath
End Sub