Allowedit property not working

Rashid

Member
Local time
Yesterday, 23:39
Joined
Sep 6, 2019
Messages
36
In my ms access DB in a form i have a button with code me. Allowedit=False
But the form is editable after the clicking button.
What is the solution.
 
In my ms access DB in a form i have a button with code me. Allowedit=False
But the form is editable after the clicking button.
What is the solution.
Post the full code for your edit button code. There could be lot's of reasons why this is happening. I suggest putting a stop at the beginning of you edit button code and analyze the variables in question that set or unset the AllowEdits property. Your posted line of code shows the 's' at the end of AllowEdits to be missing. Details matter.
 
Most likely culprit is that event is not even trapped.
For example you do not have "[event Procedure]" in the onclick property.
Easy test. After you set the property, add the following line of code
msgbox me.allowedits

If nothing pops up then this code is not firing.
 
..or maybe you have a subform and want to apply AllowEdits=false to the subform?
 
The code i am using AllowEdits=False on main form not on subform.
Is there any other vba code to get the same result.
 
The code i am using AllowEdits=False on main form not on subform.
Is there any other vba code to get the same result.
Can you post a sample db to demonstrate the problem?
 
The code i am using AllowEdits=False on main form not on subform.
Is there any other vba code to get the same result.

Try some code like this using two buttons that are positioned right on top of one another. The reason you were unable to change the AllowEdits is because the record was not saved yet. You must save the record first before changing the settings to not allow edits.
Code:
Private Sub EditBtn_Click()
   Me.AllowEdits = True
   Me.ProtectBtn.Visible = True
   Me.ProtectBtn.SetFocus
   Me.EditBtn.Visible = False
End Sub

Private Sub Form_Load()
   Me.AllowEdits = False
   Me.EditBtn.Visible = True
   Me.ProtectBtn.Visible = False
End Sub

Private Sub ProtectBtn_Click()
   Me.Dirty = False
   Me.AllowEdits = False
   Me.EditBtn.Visible = True
   Me.EditBtn.SetFocus
   Me.ProtectBtn.Visible = False
End Sub
 
Example:
Code:
Me.AllowEdits = False
me.NameOfDataField.Value = "abc"
=> User can edit data in form (record is in edit mode ... visible pensil in record selector)

Code:
Me.AllowEdits = False
me.NameOfDataField.Value = "abc"
me.Dirty = false
=> User can not edit data in form.
 

Attachments

Last edited:
The code i am using AllowEdits=False on main form not on subform.
Is there any other vba code to get the same result.
but if the intent is on the subform, not the main form:

Me.[subformName].Form.AllowEdits = False
 

Users who are viewing this thread

Back
Top Bottom