force a FileCopy to copy over the file name

  • Thread starter Thread starter Janis
  • Start date Start date
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"
 
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"
 
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
 
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/
 
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"
 
& 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"
 
Back
Top