Microsoft KB Archive/828412

= Programmatically modifying an action query in an Access database invalidates the digital signature of the Access database =

Article ID: 828412

Article Last Modified on 7/28/2006

-

APPLIES TO


 * Microsoft Office Access 2003

-



This article applies only to a Microsoft Access database (.mdb).

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



SYMPTOMS
In a Microsoft Office Access 2003 database that is digital signed, if you programmatically modify an insert query, an update query, or a delete query by using Microsoft Visual Basic Editor, the digital signature of the database may become invalid when you try to open the database. Subsequently, with the security level set to medium or to high, the Access database may not open, and you may receive the following error message:

The code or macros in this file do not match the digital signature. This mismatch was most likely caused by one of the following:

- The file was modified by a virus.

- The file was modified by an earlier version of Microsoft Access.

Check the file for viruses with an updated virus scanner, and notify the publisher of this file. The current security settings prevent Access from opening this file.

You may also receive the following warning message:

Microsoft Office Access cannot open  due to security restrictions.

Either macros are disabled or security settings restrict access to the file because it is not digitally signed.



WORKAROUND
To avoid this problem, do not programmatically modify an action query when your Access database is digitally signed.

To work around the problem that is mentioned in the &quot;Symptoms&quot; section of this article, modify the security level of the Access database to low, and then remove and then add the digital signature to the database. To do this, follow these steps:
 * 1) Start Microsoft Office Access 2003.
 * 2) On the Tools menu, point to Macro, and then click Security.
 * 3) In the Security dialog box, select the Low (not recommended). You are not protected from potentially unsafe macros. Use this setting only if you have virus scanning software installed, or you have checked the safety of all documents you open option, and then click OK.

Note You may receive an Access warning message that prompts you to confirm the security setting. Click Yes in the warning message to confirm. You may have to close and then reopen Access for the new security setting to take effect.
 * 1) Open the Access database for which the problem that is mentioned in the &quot;Symptoms&quot; section of this article occurs.
 * 2) On the Tools menu, point to Macro, and then click Visual Basic Editor.
 * 3) In the Visual Basic Editor, click Digital Signature on the Tools menu.
 * 4) In the Digital Signature dialog box, click Remove.
 * 5) In the Digital Signature dialog box, click Choose.
 * 6) In the Select Certificate dialog box, click the digital signature that you removed in step 7 in the Select the certificate you want to use list, and then click OK.
 * 7) In the Digital Signature dialog box, click OK.
 * 8) On the File menu, click Close and Return to Microsoft Office Access.
 * 9) In Microsoft Access 2003, point to Macro on the Tools menu, and then click Security.
 * 10) In the Security dialog box, select the Medium. You can choose whether or not to run potentially unsafe macros option, and then click OK.

Note You may receive an Access warning message that prompts you to confirm the security setting. Click Yes in the warning message to confirm. You may have to close and then reopen Access for the new security setting to take effect.
 * 1) Reopen the Access database. You may not notice the error messages that are mentioned in the &quot;Symptoms&quot; section of this article.



Steps to Reproduce the Behavior
Caution If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.  Start Microsoft Office Access 2003. On the Tools menu, point to Macro, and then click Security. In the Security dialog box, click to select the '''Medium. You can choose whether or not to run potentially unsafe macros option, and then click OK'''. Open the Northwind.mdb sample Access database.  Create the following query, and then save the query as EmpUpdQuery: UPDATE Employees SET FirstName = FirstName  On the Tools menu, point to Macro, and then click Visual Basic Editor.</li> In the Visual Basic Editor, click Digital Signature on the Tools menu.</li> In the Digital Signature dialog box, click Choose.</li> In the Select Certificate dialog box, click a digital signature in the Select the certificate you want to use list, and then click OK.</li> In the Digital Signature dialog box, click OK.</li> On the File menu, click Close and Return to Microsoft Office Access.</li> Close the Northwind.mdb database, and then open it again.

Note You may notice that the Security Warning message box is displayed. Click Open to open the Northwind.mdb database.</li> On the Tools menu, point to Macro, and then click Visual Basic Editor.</li> On the View menu, click Immediate Window.</li>  In the Immediate Window, type the following code, and then press ENTER: Application.CurrentDb.QueryDefs(&quot;EmpUpdQuery&quot;).SQL = &quot;SELECT * FROM Employees;&quot; </li> On the File menu, click Close and Return to Microsoft Office Access.</li> Close and then reopen the Northwind.mdb database.

You may notice the error messages that are mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">