Connecting Tech Pros Worldwide Help | Site Map

Overwrite File -"Yes"

Clint Stowers
Guest
 
Posts: n/a
#1: Nov 12 '05
Access 2k

Exporting a Query to as an excel file. No problem.

However, I keep getting the warning that the file already exists, Overwrite
Yes/No.

Yes, I want to overwrite the file. SetWarnings On/Off has no affect.

Any suggestions appreciated.

Thanks in advance.




"And.... Exactly at which point did you consider this a good idea?"
Bruce M. Thompson
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Overwrite File -"Yes"


> Access 2k[color=blue]
>
> Exporting a Query to as an excel file. No problem.
>
> However, I keep getting the warning that the file already exists, Overwrite
> Yes/No.
>
> Yes, I want to overwrite the file. SetWarnings On/Off has no affect.
>
> Any suggestions appreciated.[/color]

Have you considered checking to see if the filename exists and, if so, delete
the file prior to doing the export?

--
Bruce M. Thompson, Microsoft Access MVP
bthmpson@mvps.org (See the Access FAQ at http://www.mvps.org/access)[color=blue][color=green]
>> NO Email Please. Keep all communications[/color][/color]
within the newsgroups so that all might benefit.<<


Clint Stowers
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Overwrite File -"Yes"


In article <vro8flmvp4vo02@corp.supernews.com>, "Bruce M. Thompson"
<bthmpson@big_NOSPAM_foot.com> writes:
[color=blue]
>Have you considered checking to see if the filename exists and, if so, delete
>the file prior to doing the export?[/color]

I know how to check for the existance of the file. For fear of looking stupid
(not the first time) what would be the syntax for deleting the external file?
(i.e.: C:\MyDir\MyFile.xxx)

Else, I guess I could run a batch routine prior to running the Access App.





"And.... Exactly at which point did you consider this a good idea?"
Rick Brandt
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Overwrite File -"Yes"


"Clint Stowers" <clint2001@aol.comNoSpam> wrote in message
news:20031120074121.12501.00004082@mb-m04.aol.com...[color=blue]
> In article <vro8flmvp4vo02@corp.supernews.com>, "Bruce M. Thompson"
> <bthmpson@big_NOSPAM_foot.com> writes:
>[color=green]
> >Have you considered checking to see if the filename exists and, if so,[/color][/color]
delete[color=blue][color=green]
> >the file prior to doing the export?[/color]
>
> I know how to check for the existance of the file. For fear of looking[/color]
stupid[color=blue]
> (not the first time) what would be the syntax for deleting the external[/color]
file?[color=blue]
> (i.e.: C:\MyDir\MyFile.xxx)[/color]

Kill "path to file"

(there is no warning and it doesn't move the file to the recycle bin so use
with caution).


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Clint Stowers
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Overwrite File -"Yes"


In article <bpidbl$1pl78e$1@ID-98015.news.uni-berlin.de>, "Rick Brandt"
<rickbrandt2@hotmail.com> writes:
[color=blue]
>Kill "path to file"
>
>(there is no warning and it doesn't move the file to the recycle bin so use
>with caution).
>[/color]

Working as advertised. Thanks.



"And.... Exactly at which point did you consider this a good idea?"
Terry Kreft
Guest
 
Posts: n/a
#6: Nov 12 '05

re: Overwrite File -"Yes"


A "safer" way is to Name the file to a backup first and then write your file
out so

Where original file is C:\MyDir\MyFile.xls

' *********************************************
' Code Start
Const FILE_TARGET = "C:\MyDir\MyFile.xls"
Const FILE_BACKUP = "C:\MyDir\MyFile.bak"

If Len(Dir(FILE_TARGET)) > 0 Then
If Len(Dir(FILE_BACKUP)) > 0 Then
Kill FILE_BACKUP
End If
Name FILE_TARGET As FILE_BACKUP
End If

' Code to output the new file to FILE_TARGET
' Code End
' *********************************************

Terry


"Clint Stowers" <clint2001@aol.comNoSpam> wrote in message
news:20031120180436.07961.00000075@mb-m03.aol.com...[color=blue]
> In article <bpidbl$1pl78e$1@ID-98015.news.uni-berlin.de>, "Rick Brandt"
> <rickbrandt2@hotmail.com> writes:
>[color=green]
> >Kill "path to file"
> >
> >(there is no warning and it doesn't move the file to the recycle bin so[/color][/color]
use[color=blue][color=green]
> >with caution).
> >[/color]
>
> Working as advertised. Thanks.
>
>
>
> "And.... Exactly at which point did you consider this a good idea?"[/color]


Closed Thread