Microsoft KB Archive/295819

= ACC2002: Files That Were Not Created by Data Source Control Can Be Overwritten =

Article ID: 295819

Article Last Modified on 11/5/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q295819



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
When you use the Data Source Control in Microsoft Access to create a file, the control overwrites existing files created by other programs.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The &quot;BeforeOverwrite Event&quot; topic in the Help system for the Microsoft Script Editor in Access contains the following note:

Note: Files that were not created by the Data Source Control will not be overwritten.

When you use the Data Source Control to create a file within a folder, the control should not overwrite an existing file created by another program, even after you instruct the BeforeOverwrite event to continue. However, the file created by another program is overwritten.

Steps to Reproduce the Behavior
  Start Notepad, and then type or paste the following text:      1 Microsoft <Phone>(425)555-1212</Phone> </Table1> </Tables> </Schema> </li> <li>Save the file as C:\Test\File.xml .</li> <li>On the same computer, open the sample database Northwind.mdb.</li> <li>On the Insert menu, click Page.</li> <li>In the New Data Access Page dialog box, click AutoPage: Columnar, click the arrow in the Choose the table or query where the object's data comes from box, click Shippers in the drop-down list, and then click OK.</li> <li>When the data access page has been created, click Design View on the View menu.</li> <li>Click the Command Button tool in the toolbox, and then click within the Header: Shippers section. If the Command Button Wizard starts, click Cancel.</li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li>Click the arrow in the Object box, and then click Command0 in the drop-down list. Click the arrow in the Event box, and then click onclick in the drop-down list.</li> <li> Modify the script as follows: <SCRIPT event=onclick for=Command0 language=vbscript> </SCRIPT> </li> <li>Click the arrow in the Object box, and then click MSODSC in the drop-down list. Click the arrow in the Event box, and then click BeforeOverwrite in the drop-down list.</li> <li> Modify the script as follows, and make sure to add the objDSCEventInfo within the parentheses of this event: <SCRIPT event=BeforeOverwrite(objDSCEventInfo) for=MSODSC language=vbscript> </SCRIPT> </li> <li>On the File menu, click Save. Save the page as Page1.htm.</li> <li>On the File menu, click Exit to return to Microsoft Access.</li> <li>On the View menu, click Page View.</li> <li>Click the command button, and then click Yes when you are prompted to continue.</li> <li>Start Notepad, and then open C:\Test\File.xml.</li></ol>

Note that the original Notepad file has been overwritten. The same behavior would occur if the Notepad file had a .txt extension and the XMLDataTarget code above also specified a .txt extension. In other words, the file name is not important. If you had specified &quot;C:\Autoexec.bat&quot; in the XMLDataTarget code above, the Autoexec.bat file would have been overwritten, even though the file was not created by using the Data Source Control.

<div class="references_section">