Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Archive losing files

Status
Not open for further replies.

DWillett

Programmer
Joined
Oct 21, 2003
Messages
5
Location
GB
I'm losing files and I can't for the life of me find why !
If I select 10 files to archive, I end up with 8 in the archive folder.
I must have looked at this code umpteen times, debug.Print, step thru etc.

Can anyone see why I am losing files ??

I have remmed out the fso.DeleteFile and the Kill statement, it doesn't matter which I use, I still lose files.




VB:
--------------------------------------------------------------------------------
Private Sub CmdArchiveJPG_Click()
Dim SF As String ' Source Folder
Dim AF As String ' Archive Folder
Dim N As Integer ' Number
Dim i As Integer ' Number
Dim FN As String ' FileName
Dim FNA As String 'FileName Archived
Dim DP As String ' Default Path
Dim strFolderName As String


SF = "L:\MMPDF\Image\"
AF = "L:\MMPDF\Archive\"

Set fso = New FileSystemObject
Me.MousePointer = vbHourglass
For N = 0 To lstFiles.ListCount - 1
If lstFiles.Selected(N) Then
FN = lstFiles.List(N)

strFolderName = AF & Left$(FN, 5) & "\"

If Dir(strFolderName, vbDirectory) = "" Then
MkDir strFolderName
End If

DF = Left$(FN, Len(FN) - 3) & "IMA"
X = Shell("c:\pkware\pkzip.exe -u " & strFolderName & DF & " " & SF & FN, vbMaximizedFocus)
End If
Next N

For i = lstFiles.ListCount - 1 To 0 Step -1
If lstFiles.Selected(i) Then
FNA = lstFiles.List(i)
'fso.DeleteFile SF & FNA
'Kill SF & FNA
End If
Next i
Me.MousePointer = vbDefault

MsgBox "Files Archived", vbInformation, "Information"
Set fso = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top