Move local File to a shared drive,this not work on 2 & 3 athattach

L

ldiaz

Hello all, this is my code..
it works fine the first time, but when I tried to move a second one, it does
not work.

Please help and thanks in advanced.

Private Sub LoadFile_Click()
On Error GoTo Err_LoadFile_Click

Dim fs As Object
Dim oldPath As String, newPath As String
Dim oldpathfile As String
Dim newpathfile As String
Dim ticketNu As String
Dim stfileName As String



ticketNu = ID_Tickets_ID
oldpathfile = Path_Loc0 'Folder file is located in
newpathfilename = "Ticket-" & ticketNu & "--" ''Folder file is located in
stfileName = Mid([Path_Loc0], InStrRev([Path_Loc0], "\") + 1) 'File Name


oldPath = oldpathfile 'Folder file is located in
newPath = "W:\Ticket System\TicketFiles" 'Folder to copy file to
Set fs = CreateObject("Scripting.FileSystemObject")


'First Attachment
If Len(Me.Path_Loc1 & "") = 0 Then
fs.CopyFile oldPath, newPath & "\" & newpathfilename & "Attach 01--" &
stfileName 'To load any file
Set fs = Nothing
Path_Loc1 = "W:\Ticket System\TicketFiles" & "\" & newpathfilename & "Attach
01--" & stfileName
Me.Path_Loc0 = ""
Me.Path_Loc0.SetFocus

'Second Attachment
ElseIf Len(Me.Path_Loc1 & "") > 0 Then
s.CopyFile oldPath, newPath & "\" & newpathfilename & "Attach 02--" &
stfileName 'To load any file
Set fs = Nothing
Path_Loc2 = "W:\Ticket System\TicketFiles" & "\" & newpathfilename & "Attach
02--" & stfileName
Me.Path_Loc0 = ""
Me.Path_Loc0.SetFocus

'Third Attachment
ElseIf Len(Me.Path_Loc1 And Me.Path_Loc1 & "") > 0 Then
s.CopyFile oldPath, newPath & "\" & newpathfilename & "Attach 03--" &
stfileName 'To load any file
Set fs = Nothing
Path_Loc3 = "W:\Ticket System\TicketFiles" & "\" & newpathfilename & "Attach
03--" & stfileName
Me.Path_Loc0 = ""
Me.Path_Loc0.SetFocus

Else
MsgBox "There is not space for more than 3 attachment!", vbCritical, "Exceed
Attachments"

End If




Exit_LoadFile_Click:
Exit Sub

Err_LoadFile_Click:
MsgBox Err.Description
Resume Exit_LoadFile_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top