See post # 6
Printable View
See post # 6
Try this:Code:MsgBox (Application.Path)
Application does not support .Path :(
It does in Excel. What application are you using?
Oh yeah, sorry. I'm using Access 2002
I have it working with
VB Code:
FileCopy Application.CurrentProject.FullName, strDBLocation
but it keeps saying permission denied now :/
First, you need a backslash before the source location.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 likeVB Code:
FileCopy app.Path & "\FinancialData.mdb", strDBLocationDoes strDBLocation contain the new folder path AND the db name?VB Code:
FileCopy "c:\folder\FinancialData.mdb", "c:\otherfolder\FinancialData.mdb"
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.
i doubt if you can copy the database you are working from with filecopy, as filecopy will not work with open files
pete
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:
FileCopy "H:\JOB\FinancialData2.mdb", strDBLocation
it works fine
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
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).
But could someone explain why it copies just fine if I use
VB Code:
FileCopy "H:\JOB\FinancialData2.mdb", strDBLocation
but not with
VB Code:
FileCopy Application.CurrentProject.Fullname, strDBLocation
what does Application.CurrentProject.Fullname return?
pete
boy am I embarassed :blush:
I was writing the copy file for "FinancialData2.mdb" but the file I have open is "PayrollData.mdb"
hmmm an open file..........
pete