Results 1 to 6 of 6

Thread: [RESOLVED] Allow Duplicates

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Allow Duplicates

    Add error trapping which ignores the duplicates error.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    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

  5. #5
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Allow Duplicates

    Did you try Resume instead of GoTo?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    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
  •  



Click Here to Expand Forum to Full Width