Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-24-2007, 07:34 AM
bsncp bsncp is offline
Registered User
 
Join Date: Aug 2007
Posts: 2
bsncp is on a distinguished road
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?
Reply With Quote
Sponsored Links
  #2  
Old 08-24-2007, 07:42 AM
RuralGuy's Avatar
RuralGuy RuralGuy is offline
AWF VIP
 
Join Date: Jul 2005
Location: @ 8300' in the Colorado Rockies
Posts: 11,695
RuralGuy is a jewel in the roughRuralGuy is a jewel in the roughRuralGuy is a jewel in the roughRuralGuy is a jewel in the rough
Send a message via MSN to RuralGuy Send a message via Yahoo to RuralGuy
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, Win7
Please post back to this Forum so all may benefit.
Teaching is not filling a bucket but lighting a fire.
Reply With Quote
  #3  
Old 08-24-2007, 07:47 AM
boblarson's Avatar
boblarson boblarson is online now
Super Moderator
 
Join Date: Jan 2001
Posts: 22,003
boblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to all
Quote:
Originally Posted by RuralGuy View Post
I'll bet the warning is coming from Windows and not Access.
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
__________________
Thanks,

Bob Larson

Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool)

"Have you tried turning it off and on again?"
Reply With Quote
  #4  
Old 08-24-2007, 07:57 AM
bsncp bsncp is offline
Registered User
 
Join Date: Aug 2007
Posts: 2
bsncp is on a distinguished road
thank you! I wasn't connecting the dots that it was a warning coming from outside Access. Kill command works like a charm.
Reply With Quote
  #5  
Old 10-17-2007, 12:41 PM
feinj feinj is offline
Registered User
 
Join Date: Oct 2007
Posts: 8
feinj is on a distinguished road
Quote:
Originally Posted by boblarson View Post
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,

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.
Reply With Quote
  #6  
Old 10-17-2007, 10:23 PM
boblarson's Avatar
boblarson boblarson is online now
Super Moderator
 
Join Date: Jan 2001
Posts: 22,003
boblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to all
Quote:
Originally Posted by feinj View Post
Bob,

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.
What was your procedure you used (the whole thing) and where did you put it?
__________________
Thanks,

Bob Larson

Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool)

"Have you tried turning it off and on again?"
Reply With Quote
  #7  
Old 10-18-2007, 07:21 AM
feinj feinj is offline
Registered User
 
Join Date: Oct 2007
Posts: 8
feinj is on a distinguished road
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.
Reply With Quote
  #8  
Old 10-18-2007, 07:33 AM
Zigzag's Avatar
Zigzag Zigzag is offline
Registered User
 
Join Date: Aug 2007
Location: Bromsgrove, West Midlands, UK
Posts: 386
Zigzag will become famous soon enough
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.
Reply With Quote
  #9  
Old 10-18-2007, 08:02 AM
feinj feinj is offline
Registered User
 
Join Date: Oct 2007
Posts: 8
feinj is on a distinguished road
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??
Reply With Quote
  #10  
Old 10-18-2007, 08:29 AM
feinj feinj is offline
Registered User
 
Join Date: Oct 2007
Posts: 8
feinj is on a distinguished road
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.
Reply With Quote
  #11  
Old 10-18-2007, 08:45 AM
Zigzag's Avatar
Zigzag Zigzag is offline
Registered User
 
Join Date: Aug 2007
Location: Bromsgrove, West Midlands, UK
Posts: 386
Zigzag will become famous soon enough
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.
Reply With Quote
  #12  
Old 10-30-2007, 05:47 AM
PMOB PMOB is offline
Registered User
 
Join Date: Oct 2007
Posts: 3
PMOB is on a distinguished road
If you're doing this via a macro you can also use the Transferspreadsheet function - it will overwrite the existing files without asking.
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Death Of A President Mile-O Politics & Current Events 95 10-19-2006 11:47 PM
Turn of warnings on DB startup - Is this possible? Keith Nichols General 26 08-03-2006 07:02 AM
Pop Up Message Ukraine82 Forms 7 06-15-2004 03:24 AM
Can't bind 3 pop ups to one record BarryMK Forms 3 10-29-2002 03:24 AM


All times are GMT -8. The time now is 09:54 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World