Form.
You can use the AllowAdditions property to specify whether a user can add a record using a form.
The AllowAdditions property uses the following settings.
Setting | Description | Visual Basic |
Yes | (Default) The user can add new records. | True (-1) |
No | The user cant add new records | False (0) |
You can set the AllowAdditions property in the forms property sheet, a macro, or using Visual Basic.
Set the AllowAdditions property to No to allow users to view or edit existing records but not add new records.
If you want to prevent changes to existing records (make a form read-only), set the AllowAdditions, AllowDeletions, and AllowEdits properties to No. You can also make records read-only by setting the RecordsetType property to Snapshot.
If you want to open a form for data entry only, set the forms DataEntry property to Yes.
When AllowAdditions is set to No, the Data Entry command on the Records menu is not available.
AllowDeletions Property, AllowEdits Property, DataEntry Property, RecordsetType Property.
The following example examines the ControlType property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect property for those controls. When the label controls SpecialEffect property is set to Shadowed and the Text box controls SpecialEffect property is set to Normal and the AllowAdditions, AllowDeletions, and AllowEdits properties are all set to True.
Sub ToggleControl(frm As Form)ctlCurrentControl As ControlintI As Integer, intCanEdit As IntegerconTransparent = 0conWhite = 16777215intI = 0 To frm.Count - 1 Set ctlCurrentControl = frm(intI) Select Case ctlCurrentControl.ControlType Case acLabel If ctlCurrentControl.SpecialEffect = acEffectShadow Then ctlCurrentControl.SpecialEffect = acEffectNormal ctlCurrentControl.BorderStyle = conTransparent intCanEdit = True Else ctlCurrentControl.SpecialEffect = acEffectShadow intCanEdit = False End If Case acTextBox If ctlCurrentControl.SpecialEffect = acEffectNormal Then ctlCurrentControl.SpecialEffect = acEffectSunken ctlCurrentControl.BackColor = conWhite Else ctlCurrentControl.SpecialEffect = acEffectNormal ctlCurrentControl.BackColor = frm.Detail.BackColor End If End SelectintI If intCanEdit = False Then frm.AllowAdditions = False frm.AllowDeletions = False frm.AllowEdits = False Else frm.AllowAdditions = True frm.AllowDeletions = True frm.AllowEdits = True End IfSub