|
-
Feb 9th, 2012, 11:18 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Allow Duplicates
Hi
When I use the code below all is fine unless there is a duplicate then it creates an error.
Q. How can I allow duplicates?
Code:
If Dir(xCopyStrPath & .strArtist & sString) <> vbNullString Then
Kill xCopyStrPath & .File1.FileName
Else
Name xCopyStrPath & .File1.FileName As xCopyStrPath & sString
End If
-
Feb 9th, 2012, 11:52 AM
#2
Re: Allow Duplicates
Add error trapping which ignores the duplicates error.
-
Feb 9th, 2012, 12:07 PM
#3
Thread Starter
Hyperactive Member
Re: Allow Duplicates
Hi Hack
I am doing that at the moment with a resume next this does not implement the desired change.
Is there another solution?
PS Sorry did not show this in my post as I try not to use this escape, and will only use it for test purposes.
-
Feb 11th, 2012, 03:58 AM
#4
Thread Starter
Hyperactive Member
Re: Allow Duplicates
Hi
I added the error trap to overcome duplicates and this works fine if there is only one duplicate but not if there is two, is there a way to resolve this please.
Code:
If Dir(xCopyStrPath & .strArtist & sString) <> vbNullString Then
Kill xCopyStrPath & .File1.FileName
Else
Loop_Repeat:
Name xCopyStrPath & .File1.FileName As xCopyStrPath & sString
End If
End With
DuplicateFile:
If Err.Number = 58 Then
iLen = Len(sString) - 3
sExtn = Right$(sString, 3)
sString = Left$(sString, iLen) & "." & sExtn
Err.Number = 0
GoTo Loop_Repeat
End If
-
Feb 11th, 2012, 03:16 PM
#5
Re: Allow Duplicates
Did you try Resume instead of GoTo?
-
Feb 20th, 2012, 07:26 AM
#6
Thread Starter
Hyperactive Member
Re: Allow Duplicates
Hi dillettante
Sorry this is a bit late from your post I have been trying to resolve another problem and did not have time to retest your suggestion.
I am now glad I did because it does resolve the problem.
Thanks very much for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|