Results 1 to 16 of 16

Thread: [Resolved] Permission Denied - FileCopy

  1. #1

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Stupid Question -- App.Path

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

    Art . . . . Carlisle, PA . . USA

  3. #3

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Stupid Question -- App.Path

    Application does not support .Path

  4. #4
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    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

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Stupid Question -- App.Path

    Oh yeah, sorry. I'm using Access 2002

  6. #6

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  8. #8

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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 2004
    Posts
    25,618

    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

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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 2004
    Posts
    25,618

    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
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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).

  13. #13

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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 2004
    Posts
    25,618

    Re: Permission Denied - FileCopy

    what does Application.CurrentProject.Fullname return?

    pete

  15. #15

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    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 2004
    Posts
    25,618

    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
  •  



Click Here to Expand Forum to Full Width