| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
|||
|
|||
|
Warnings off, but still get pop-up
I have a simple Output macro that exports a table to Excel. My warnings are off, but I still get asked if I want to replace the existing file. How do I eliminate this?
|
| Sponsored Links |
|
#2
|
||||
|
||||
|
How about testing for the existance of the file first and delete it if it exists. I'll bet the warning is coming from Windows and not Access.
__________________
(RG for short) aka Allan Bunch MS Access MVP acXP, ac07 - WinXP Pro, Win7Please post back to this Forum so all may benefit. Teaching is not filling a bucket but lighting a fire. |
|
#3
|
||||
|
||||
|
This is definitely the case as it is a file system warning and not an Access warning. So, do as RG suggests and test for the file's existence first, if it exists you can choose to kill it first and then get no warning:
Code:
If Dir(strFileNameAndPath)<> "" Then
Kill(strFileNameAndPath)
DoCmd.OutputTo...
Else
DoCmd.OutputTo...
End If
__________________
Bob Larson Free Access Tutorials and Samples: http://www.btabdevelopment.com (and FREE frontend auto update enabling tool) |
|
#4
|
|||
|
|||
|
thank you! I wasn't connecting the dots that it was a warning coming from outside Access. Kill command works like a charm.
|
|
#5
|
|||
|
|||
|
Quote:
I am new to this process. Can you give me an example of this code as setup in a custom function where I test for an existing file and delete it before running a Output To Function. I tried to create the module for this purpose an could not get the procedure to debug. |
|
#6
|
||||
|
||||
|
Quote:
__________________
Bob Larson Free Access Tutorials and Samples: http://www.btabdevelopment.com (and FREE frontend auto update enabling tool) |
|
#7
|
|||
|
|||
|
kill File Function
I am usiing the followilng code while creating a new module:
Public Function KillFile Kill(S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls) End Function I keep getting the message; Compile Error: Expected Identifier during debug. Please help. I need to replace an existing file without getting the message "file already exists" from the operation system. I have never created a module, procedure, or function before. However, the need is great. |
|
#8
|
||||
|
||||
|
I dont think you need the "Killfile" so try without it.
Also put your strFileNameAndPath into quotes. If Dir("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls")<> "" Then Kill("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls") DoCmd.OutputTo... Else DoCmd.OutputTo... End If Garry
__________________
http://www.sentineluk.co.uk The impossible is possible. Miracles take a little longer. |
|
#9
|
|||
|
|||
|
kill File Function
Thanks for the help Gary,
I plugged in the following code: If Dir("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls") <> "" Then Kill ("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls") DoCmd.OutputTo ("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls") Else DoCmd.OutputTo ("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls") End If Now I am getting the error message during debug: "Invalid Outside Procedure" where on the first line of code the following is highlighted "S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls" What am I doing wrong now?? |
|
#10
|
|||
|
|||
|
kill File Function
Hey Gary,
Success at last. I did some additional experimentation and was able to use what you gave me and combine it with the DoCmd output from a standard macro with the OutputTo Action after having converted the macro to VBA. The function I ended up with looks like this below: Public Function KillFile() If Dir("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls") <> "" Then Kill ("S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls") DoCmd.OutputTo acQuery, "Open Tasks for Interface", "MicrosoftExcelBiff8(*.xls)", "S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls", False, "", 0 Else DoCmd.OutputTo acQuery, "Open Tasks for Interface", "MicrosoftExcelBiff8(*.xls)", "S:\FEIN\Kanban Systems in Access\Kanban Oracle Interface\Kanban Oracle Interface.xls", False, "", 0 End If End Function Thanks so much for the help. |
|
#11
|
||||
|
||||
|
Glad to hear that you got there in the end
![]() Garry
__________________
http://www.sentineluk.co.uk The impossible is possible. Miracles take a little longer. |
|
#12
|
|||
|
|||
|
If you're doing this via a macro you can also use the Transferspreadsheet function - it will overwrite the existing files without asking.
|
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Death Of A President | Mile-O | Politics & Current Events | 95 | 10-20-2006 12:47 AM |
| Turn of warnings on DB startup - Is this possible? | Keith Nichols | General | 26 | 08-03-2006 08:02 AM |
| Pop Up Message | Ukraine82 | Forms | 7 | 06-15-2004 04:24 AM |
| Can't bind 3 pop ups to one record | BarryMK | Forms | 3 | 10-29-2002 04:24 AM |