XL: "Unable to Write to Database" Error with Template Wizard

Last reviewed: January 7, 1998
Article ID: Q171579
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a

SYMPTOMS

If you use a template created by the Template Wizard to create a new record in a database, you may receive the following error message:

   Unable to write to database. Make sure database is not protected and
   has valid field data-types.

CAUSE

This problem may occur if all of the following conditions are true:

  • You are using a Microsoft Access database.

        -and-
    
  • The table in which you save the records has a primary field.

        -and-
    
  • The data type for the primary field is set to Number instead of the AutoNumber default type.

    NOTE: The data type for the primary field is set to number if you created the database in Microsoft Access.

        -and-
    
  • In the Template Wizard, you do not link the primary field to any cells on the worksheet.

When you use a template created by the Template Wizard to create new records in the table, any fields of the Number type that are not explicitly linked to worksheet cells receive a value of zero each time you save a new record. Therefore, if the primary key is set to the Number data type and you try to save the second record to the table, you receive the error message described in this article. This behavior occurs because the primary key cannot have the same value (in this case zero) in multiple records in the same table.

RESOLUTION

To resolve this problem, change the data type of the primary field to AutoNumber. After you do this, Microsoft Access generates a unique number for this field for each record in the table.

STATUS

This behavior is by design of the Template Wizard in Microsoft Excel.

MORE INFORMATION

The Template Wizard with Data Tracking add-in creates a template that links selected cells in a workbook to fields in a database. When you base a new workbook on the template and enter data in the linked cells, Microsoft Excel creates a new record in the database and copies the data to the corresponding data fields.

REFERENCES

For more information about the Template Wizard, click the Office Assistant, type "template wizard," click Search, and then click to view " What is the Template Wizard with Data Tracking?"

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office
               Program or Component


Additional query words: XL97
Keywords : xladdins xlwiz kberrmsg kbinterop kbtool
Version : WINDOWS:7.0,7.0a,97
Platform : WINDOWS
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 7, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.