Microsoft KB Archive/122673

= ACC2: Cannot Add Record After Changing DefaultEditing Property =

Article ID: 122673

Article Last Modified on 11/6/2000

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q122673





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

If you open a form with the form's DefaultEditing property set to Can't Add Records, using Access Basic code from a global module to set the DefaultEditing property to Allow Edits will not cause the form to allow new records to be added.



RESOLUTION
One way to work around this problem is to first set the DefaultEditing property to Data Entry, and then to Allow Edits. The following example demonstrates how to add a command button to a form that will set the DefaultEditing property so that you can add new records.

CAUTION: Following the steps in this example will modify the sample database NWIND.MDB. You may want to back up the NWIND.MDB file, or perform these steps on a copy of the NWIND database.

 Start Microsoft Access and open the sample database NWIND.MDB. Open the Customers form in Design view. Set the form's DefaultEditing property to Can't Add Records. Add a command button named Add to the form.  Set the new command button's OnClick property to the following event procedure:

Sub Add_Click Me.DefaultEditing = 1  'Sets DefaultEditing to Data Entry Me.DefaultEditing = 2  'Sets DefaultEditing to Allow Edits End Sub  Save the form, and then close it.</li> Open the form in Form view. Note that you cannot add new records.</li> Choose the Add button. Note that you can add new records.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0

<div class="moreinformation_section">

Steps to Reproduce Problem

 * 1) Follow steps 1-3 in the "Resolution" section above.
 * 2) Save the form, close it, and then open it in Form view. Note that you cannot add new records.
 * 3) Create a new module and then choose Immediate Window from the File menu.
 * 4) Type the following line in the Immediate window and then press ENTER:

Forms![Customers].DefaultEditing = 2


 * 1) Select the Customers form. Note that you still cannot add new records.

<div class="references_section">