Results 1 to 16 of 16

Thread: [Resolved] Permission Denied - FileCopy

  1. #1
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Resolved [Resolved] Permission Denied - FileCopy

    See post # 6
    Last edited by kfcSmitty; Jun 21st, 2005 at 09:17 AM.

  2. #2
    Frenzied Member
    Join Date
    May 04
    Location
    Carlisle, PA
    Posts
    1,044

    Re: Stupid Question -- App.Path

    Try this:
    Code:
    MsgBox (Application.Path)
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  3. #3
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Re: Stupid Question -- App.Path

    Application does not support .Path

  4. #4
    Frenzied Member
    Join Date
    May 04
    Location
    Carlisle, PA
    Posts
    1,044

    Re: Stupid Question -- App.Path

    It does in Excel. What application are you using?
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  5. #5
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Re: Stupid Question -- App.Path

    Oh yeah, sorry. I'm using Access 2002

  6. #6
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Re: Stupid Question -- App.Path

    I have it working with

    VB Code:
    1. FileCopy Application.CurrentProject.FullName, strDBLocation

    but it keeps saying permission denied now :/

  7. #7
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283

    Re: Stupid Question -- App.Path

    First, you need a backslash before the source location.
    VB Code:
    1. FileCopy app.Path & "\FinancialData.mdb", strDBLocation
    Second, FileCopy is going to want the name of the file. In other words, if we weren't using a variable, the copy would look like
    VB Code:
    1. FileCopy "c:\folder\FinancialData.mdb", "c:\otherfolder\FinancialData.mdb"
    Does strDBLocation contain the new folder path AND the db name?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  8. #8
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Re: Permission Denied - FileCopy

    yes, if I enter in the code I had before it would work if I hardcoded the database name.

    Now my problem is, it is reading the proper file, and tryign to save to the proper location, but it says permission denied now.

  9. #9
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,532

    Re: Permission Denied - FileCopy

    i doubt if you can copy the database you are working from with filecopy, as filecopy will not work with open files

    pete

  10. #10
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Re: Permission Denied - FileCopy

    is there a command that will work with opened files?

    Its weird, cause it copied it once when I had the file open (when I hardcoded the filename and path), but now it wont

    verified - if I use

    VB Code:
    1. FileCopy "H:\JOB\FinancialData2.mdb", strDBLocation

    it works fine

  11. #11
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,532

    Re: Permission Denied - FileCopy

    you may be able to close the access application first then do file copy, i am not sure if that would work, but otherwise use the access saveAs command, to save the database to another location

    pete

  12. #12
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283

    Re: Permission Denied - FileCopy

    Hmmm....I probably should have guessed, since this is VBA, that the file would be open.

    Anyway, I don't believe you are going to be able to issue code from within a database to copy itself while it is open. The FSO in VB will copy an open file, but the code to do the copy if coming from VB, not from within the file itself.

    I think the best way to solve this little problem is to write a tiny little VB app that will do the copy for you (providing the databse is closed, of course).
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  13. #13
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Re: Permission Denied - FileCopy

    But could someone explain why it copies just fine if I use

    VB Code:
    1. FileCopy "H:\JOB\FinancialData2.mdb", strDBLocation

    but not with

    VB Code:
    1. FileCopy Application.CurrentProject.Fullname, strDBLocation

  14. #14
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,532

    Re: Permission Denied - FileCopy

    what does Application.CurrentProject.Fullname return?

    pete

  15. #15
    Frenzied Member kfcSmitty's Avatar
    Join Date
    May 05
    Location
    Kingston, Ontario
    Posts
    1,789

    Re: Permission Denied - FileCopy

    boy am I embarassed

    I was writing the copy file for "FinancialData2.mdb" but the file I have open is "PayrollData.mdb"

  16. #16
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,532

    Re: [Resolved] Permission Denied - FileCopy

    hmmm an open file..........


    pete

Posting Permissions

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