Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FileCopy not copying (VBA (Access 2000))

    I am trying to use the following code to copy a file, the file definately exists in that location and the destination folder definately exists. I am not getting an error message at all but the file is simply not copying.

    FileCopy ":AppsOperaIIDataB_wname.fpt", _
    "SatabaseColdB_wname.dbf"

    Any suggestions would be appreciated.

    Amanda

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    There is no drive letter in the source path...

  3. #3
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    Hans,

    Sorry, that was a typing error when I copied the code, it should read:

    FileCopy "F:AppsOperaIIDataB_wname.fpt", _
    "SatabaseColdB_wname.dbf"

    Any suggestions would be appreciated.

    Amanda

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    Do you have error handling in the procedure that contains this line, i.e. a line of the form

    On Error GoTo <labelname>

    or

    On Error Resume Next

  5. #5
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    Hans,

    Yep, On error resume next that I hadn't set back to On error goto 0.
    Thanks for that.

    Amanda

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    Do you get an error message now, after resetting the error handling?

  7. #7
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    I think S: is a "drive" mapped to a network location. I had the same problem a while back. In that case this codesnippet I found once on the internet might help:

    FileCopy "F:AppsOperaIIDataB_wname.fpt", _
    GetUNCPath("S:") & "DatabaseColdB_wname.dbf"

    <pre>Declare Function WNetGetConnection Lib "mpr.dll" _
    Alias "WNetGetConnectionA" _
    (ByVal lpszLocalName As String, _
    ByVal lpszRemoteName As String, _
    cbRemoteName As Long) As Long
    </pre>

    <pre>Public Function GetUNCPath(strDrivePath As String) As String
    'strDrivePath = drive-letter + : ( i.e. "Z:" )
    Dim strTemp As String
    Dim lngReturn As Long

    strTemp = Space(255)
    lngReturn = WNetGetCon@nection(strDrivePath, strTemp, 255)
    If lngReturn = 0 Then
    strTemp = Trim(strTemp)
    GetUNCPath = Left(strTemp, Len(strTemp) - 1)
    Else
    GetUNCPath = "ERROR - " & CStr(lngReturn)
    End If
    End Function
    </pre>


  8. #8
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    Jan

    That's very useful thanks. I will use it.

    Amanda

  9. #9
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FileCopy not copying (VBA (Access 2000))

    Problem is now solved thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •