Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2014
    Posts
    4

    unable to copy file

    i am novice to access and trying to copy file from source folder to destination folder using following code in access but its not working

    Private Sub Command9_Click()



    Dim strSource As String
    Dim strDest As String
    Dim sPath As String

    strSource = Forms!frmScanUpload.txtfilename '- Path/Name of the file to be copied

    Me.DocName = DocNameGenerat.Value

    strDest = CurrentProject.Path & "\ScanDocument\" & Format(Me.DocName) & ".pdf" '- Path/Name for copying to file to

    Call FileCopy(strSource, strDest)

    MsgBox "File Transferred"


    Me.DocName = "#" & strDest & "#"

    End Sub


    request to do correct the code

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Do you have a Procedure named "FileCopy"?
    If not, I don't think you want to use the "Call" command. You usually use that to Call other procedures you have created.
    If you are just trying to using Access's FileCopy command, drop the word "Call".

    If it still does not work, make sure that you are referencing a valid, existing file to copy, and the location you are copying to actually exists.
    You can do that with a message box, i.e.
    Code:
    MsgBox "Copy from: " & strSource & vbCrLf & "Copy to: " & strDest

  3. #3
    Join Date
    Jul 2014
    Posts
    4
    ok got it

    thanks

    msg box shows as follows
    Click image for larger version. 

Name:	msgbox.JPG 
Views:	4 
Size:	98.8 KB 
ID:	18141

    message clearly shows source path along with file and destination path + file

    However the file is not copied to destinated folder

    if you required further information let me know

    many thanks

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Did you try making the change I mentioned in the first part of my previous reply?

  5. #5
    Join Date
    Jul 2014
    Posts
    4
    yes i remove "call"

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I tested it out, and you actually need to remove the parentheses too, i.e.:
    Code:
    FileCopy strSource, strDest
    I tested it out, and it works. So as long as you have valid file paths and names, it should work.
    If it does not, I imagine you should be getting errors. If you are, what are the error codes/messages?

  7. #7
    Join Date
    Jul 2014
    Posts
    4
    now it works

    thank you very much!!!!

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Excellent! Glad I could help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 08-16-2014, 11:20 AM
  2. Replies: 1
    Last Post: 07-02-2014, 12:27 PM
  3. Copy Open db file
    By gg80 in forum Programming
    Replies: 4
    Last Post: 04-24-2013, 04:35 PM
  4. How to copy a file from one folder to another in vba
    By pkstormy in forum Code Repository
    Replies: 2
    Last Post: 09-20-2012, 05:32 PM
  5. Copy file to folder
    By tpcervelo in forum Programming
    Replies: 11
    Last Post: 08-31-2010, 10:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums