ACC2000: Form Is Editable When AllowEdits Property Set to False (200590)
The information in this article applies to:
This article was previously published under Q200590 SYMPTOMSModerate: Requires basic macro, coding, and interoperability skills.
When you open a Microsoft Access form that has the AllowEdits property set to No (False), you can still edit the fields on that form.
CAUSE
This behavior occurs if you set the value of a control programmatically in
the Current event of the form. It also occurs if you set the value of a
control in the Load event of the form. In that case, however, the only
record that you can edit is the first record that is displayed on the form.
RESOLUTIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
If you need to edit the values of bound fields programmatically in forms
that have the AllowEdits property set to False, edit those fields in the RecordsetClone of the form, and not in the form itself.
The following example demonstrates how to create Visual Basic code in the
Current event of a form that can change the values of fields in the
RecordsetClone of a form.
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 Access and open the sample database Northwind.mdb.
- Open the Customers form in Design view.
- Set the AllowEdits property of the form to No.
- Set the OnCurrent property of the form to the following event procedure:
Private Sub Form_Current()
Dim rs As Recordset
Set rs = Me.RecordsetClone
rs.Bookmark = Form.Bookmark
rs.Edit
' The following updates the CompanyName field to itself plus the
' letter "a".
rs!CompanyName = rs!CompanyName & "a"
rs.Update
End Sub
- Save the form and open it in Form view. Note that each time you view a record, the letter "a" is appended to the Company Name, but you cannot
edit any of the fields on the form.
REFERENCESFor more information about the AllowEdits property, click Microsoft Access Help on the Help menu, type AllowEdits property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about the RecordSetClone property, click Microsoft Access Help on the Help menu, type RecordSetClone property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Major | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbdta kbprb kbusage KB200590 |
---|
|