Allowedit property not working (1 Viewer)

Rashid

Member
Local time
Yesterday, 21:31
Joined
Sep 6, 2019
Messages
30
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.
 

Mike Krailo

Well-known member
Local time
Today, 00:31
Joined
Mar 28, 2020
Messages
1,044
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:31
Joined
May 21, 2018
Messages
8,529
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:31
Joined
May 7, 2009
Messages
19,245
..or maybe you have a subform and want to apply AllowEdits=false to the subform?
 

Rashid

Member
Local time
Yesterday, 21:31
Joined
Sep 6, 2019
Messages
30
The code i am using AllowEdits=False on main form not on subform.
Is there any other vba code to get the same result.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:31
Joined
Oct 29, 2018
Messages
21,474
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?
 

Mike Krailo

Well-known member
Local time
Today, 00:31
Joined
Mar 28, 2020
Messages
1,044
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
 

Josef P.

Well-known member
Local time
Today, 06:31
Joined
Feb 2, 2023
Messages
827
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

  • TestAllowEdits.zip
    24.1 KB · Views: 31
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:31
Joined
May 7, 2009
Messages
19,245
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

Top Bottom