Solved

Can I Stop Access 2007 from asking "Do You Want To Replace The Existing File?

Posted on 2013-11-08
6
601 Views
Last Modified: 2013-11-19
I am using Access 2007 and have what I believe is a simple Macro. I basically want to output a Report to a folder on my PC. Each time I run the Macro it asks me "Do I want to replace the existing file? (I do not want to see this prompt)
I attached a jpeg of the Macro Action Arguments that I used alng with the prompt.

Is there a simple way to eliminate the prompt as I want to run this Macro as an
"AutoExec" macro?

If there is special coding to be done, please explain where as I am not an Access Expert.

Any help would be greatly appreciated.
Rick
AccessMacroError.jpg
0
Comment
Question by:ES-Components
  • 3
  • 2
6 Comments
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 500 total points
ID: 39633809
If you delete the file first, it will not prompt to replace.

Here is a function yu can put in a standard module and call from a macro


Public Function KillProperly(pKillfile As String)
    If Len(Dir(pKillfile)) > 0 Then
        SetAttr pKillFile, vbNormal
        Kill pKillFile
    End If
End Function

Open in new window

0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39633812
change the action OutputTo in your macro with

RunCode




Function Name ExportReport()


then create this function in a regular module

Function exportReport()
Dim fPath As String, fName As String
fPath = "\\Server\escfiles\Intranet\ControlPanel\Word\"
fName = "ARCollections-All.rtf"

If Dir(fPath & fName) <> "" Then Kill fPath & fName
DoCmd.OutputTo acOutputReport, "ARCollections-All", acFormatRTF, fPath & fName, no, , , acExportQualityPrint
End Function



.
0
 
LVL 21
ID: 39634095
I forgot to add that you would add the following before the Output line:

Action: RunCode
KillProperly("\\Server\escfiles\Intranet\ControlPanel\Word\ARCollections-All.rtf")
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:ES-Components
ID: 39634280
capricorn1
I think I got it to work. But there is another error.
Any ideas as to how to get this fixed?
See attached jpeg's for macro and error message

Thank you...
Rick
AccessMacro2.jpg
AccessMacro2Error.jpg
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39634321
read the messages from the error window,
check if any of those applies to your case, it is pretty straightforward
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39661167
;-) ?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now