force a FileCopy to copy over the file name

J

Janis

If you want to force a FileCopy command to write over the previous file each
time the script is run how do you do it? The .mdbz file copy is a copy of
the database saved before the database is compacted. In case there is some
corruption or something there is a backup. There is some error checking in
the script so the next time the script is run the old .mdbz file isn't needed
since I assume the database is okay since the user would have to run the
script from a button on_click event from a form in the database. If it made
it through the script the first time then everythig should have gone well. I
just want this fileCopy to copy to the same name each time the script is run.

tnx,
FileCopy "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" & "z"
 
K

Ken Snell [MVP]

Test to see if the previous file is already there, and if it is, delete it:

If Dir("Z:\SwimClub\acsc_be.mdb" & "z") <> "" Then _
Kill "Z:\SwimClub\acsc_be.mdb" & "z"
FileCopy "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" & "z"
 
P

Pieter Wijnen

tsk. tsk
you should know better than using zero length string comparison in vb :)
as a general rule *always* use:
if vba.strings.len([yourstring])=0 then

pieter
 
D

Douglas J. Steele

While I agree Len is superior, there's no real need for vba.strings.len:
vba.len (or even just Len) works fine.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Pieter Wijnen"
tsk. tsk
you should know better than using zero length string comparison in vb :)
as a general rule *always* use:
if vba.strings.len([yourstring])=0 then

pieter

Ken Snell said:
Test to see if the previous file is already there, and if it is, delete
it:

If Dir("Z:\SwimClub\acsc_be.mdb" & "z") <> "" Then _
Kill "Z:\SwimClub\acsc_be.mdb" & "z"
FileCopy "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" & "z"

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
P

Pieter Wijnen

depends on your trust in other libraries beeing available- or in my case
just showing of ;-)

pieter

Douglas J. Steele said:
While I agree Len is superior, there's no real need for vba.strings.len:
vba.len (or even just Len) works fine.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Pieter Wijnen"
tsk. tsk
you should know better than using zero length string comparison in vb
:)
as a general rule *always* use:
if vba.strings.len([yourstring])=0 then

pieter

Ken Snell said:
Test to see if the previous file is already there, and if it is, delete
it:

If Dir("Z:\SwimClub\acsc_be.mdb" & "z") <> "" Then _
Kill "Z:\SwimClub\acsc_be.mdb" & "z"
FileCopy "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" & "z"

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



If you want to force a FileCopy command to write over the previous file
each
time the script is run how do you do it? The .mdbz file copy is a copy
of
the database saved before the database is compacted. In case there is
some
corruption or something there is a backup. There is some error
checking in
the script so the next time the script is run the old .mdbz file isn't
needed
since I assume the database is okay since the user would have to run
the
script from a button on_click event from a form in the database. If it
made
it through the script the first time then everythig should have gone
well. I
just want this fileCopy to copy to the same name each time the script
is run.

tnx,
FileCopy "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" & "z"
 
P

Pieter Wijnen

& you should *never* *ever* use "" but (again fully qualified)
vba.constants.vbnullstring

pieter
(miereneuker)


"Pieter Wijnen"
depends on your trust in other libraries beeing available- or in my case
just showing of ;-)

pieter

Douglas J. Steele said:
While I agree Len is superior, there's no real need for vba.strings.len:
vba.len (or even just Len) works fine.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Pieter Wijnen"
tsk. tsk
you should know better than using zero length string comparison in vb
:)
as a general rule *always* use:
if vba.strings.len([yourstring])=0 then

pieter

"Ken Snell [MVP]" <[email protected]> skrev i melding
Test to see if the previous file is already there, and if it is, delete
it:

If Dir("Z:\SwimClub\acsc_be.mdb" & "z") <> "" Then _
Kill "Z:\SwimClub\acsc_be.mdb" & "z"
FileCopy "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" & "z"

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



If you want to force a FileCopy command to write over the previous
file each
time the script is run how do you do it? The .mdbz file copy is a
copy of
the database saved before the database is compacted. In case there
is some
corruption or something there is a backup. There is some error
checking in
the script so the next time the script is run the old .mdbz file isn't
needed
since I assume the database is okay since the user would have to run
the
script from a button on_click event from a form in the database. If it
made
it through the script the first time then everythig should have gone
well. I
just want this fileCopy to copy to the same name each time the script
is run.

tnx,
FileCopy "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" & "z"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top