Microsoft KB Archive/128220

= ACC2: Setting DefaultEditing with Access Basic Causes Requery =

Article ID: 128220

Article Last Modified on 7/5/2002

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q128220



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



SYMPTOMS
When you use Access Basic to set a form's DefaultEditing property to Can't Add Records, or change its DefaultEditing property from Can't Add Records to Read Only or Allow Edits, the form requeries, returning to the first record in the recordset.



RESOLUTION
To work around this problem, before setting the DefaultEditing property, store the primary key value in a variable. Then, use the FindRecord macro action or the Access Basic FindFirst method in the form's recordset clone to find a record.



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.



Steps to Reproduce Problem
 Open the sample database NWIND.MDB. View the Products form in Design view. Add a command button to the form.  Set the command button's OnClick property to the following event procedure:

Sub Button143_Click ' Sets DefaultEditing property to Can't Add Records. Me.DefaultEditing = 4 End Sub   Add a second command button to the form and then set the command button's OnClick property to the following event procedure:

Sub Button144_Click ' Sets DefaultEditing property to Allow Edits. Me.DefaultEditing = 2 End Sub </li> View the Product form in Form view.</li> From the Records menu, choose Go To, and then choose Last on the menu that appears.</li> Choose the first command button to set the DefaultEditing property to Can't Add Records. Note that the form requeries, returning to the first record.</li> From the Records menu, choose Go To. Note that the New command is not available on the record that appears. Choose Last.</li> Choose the second command button to set the DefaultEditing property to Allow Edits. Note that the form requeries, returning to the first record.</li></ol>

<div class="references_section">