me.allowedits (1 Viewer)

TajikBoy

Member
Local time
Today, 09:09
Joined
Mar 4, 2011
Messages
82
Hi Guys,

I'm trying to use 'me.allowedits = false' statement in one of my forms but it doesn't make diddly doo difference, I put it in the load section of the form, is there a magic trick to make it work?

Or, is there any other easy way to make the form read only, there are plenty of text/combo boxes, so going one by one is not an option for me

Thanks in advance and have a wonderful Sunday !
 

bob fitz

AWF VIP
Local time
Today, 17:09
Joined
May 23, 2011
Messages
4,727
Try in the OnOpen event or in the OnCurrent event
 

bob fitz

AWF VIP
Local time
Today, 17:09
Joined
May 23, 2011
Messages
4,727
Keep in mind that setting the AllowEdits property to False will still allow users to ADD new records and DELETE existing records
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:09
Joined
Sep 12, 2006
Messages
15,660
setting that to false should work, but it may also stop combo boxes from working.
Command buttons will still work, and you can change things in code - just not with normal keyboard actions.

Add a command button to show the allow edits status

msgbox "Allow Edits = " & me.allowedits
 

TajikBoy

Member
Local time
Today, 09:09
Joined
Mar 4, 2011
Messages
82
OnOPen and onCurrent, both also not resulting properly,

Code I am using is below, placed to msgboxes to see , firts one confirms its "Read' and second one also confirms form edit is False, still editable though

Code:
Private Sub Form_Open(Cancel As Integer)
Dim Class As String
Class = Forms("frmStatus").strClass
MsgBox Class, vbOKOnly
If Class = "Read" Then
    Me.AllowEdits = False
Else
    Me.AllowEdits = True
End If
MsgBox "Allow Edits = " & Me.AllowEdits
End Sub
 

bob fitz

AWF VIP
Local time
Today, 17:09
Joined
May 23, 2011
Messages
4,727
Why not just use:
Code:
Private Sub Form_Open(Cancel As Integer)

    Me.AllowEdits = False

    MsgBox "Allow Edits = " & Me.AllowEdits
    
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:09
Joined
May 7, 2009
Messages
19,247
you put it on the Current event:
if "frmStatus" is the same form where you are putting the code:
Code:
Private Sub Form_Current()
Dim Class As String
Class = Forms("frmStatus").strClass & ""
MsgBox Class, vbOKOnly
If Class = "Read" Then
    Me.AllowEdits = False
Else
    Me.AllowEdits = True
End If
MsgBox "Allow Edits = " & Me.AllowEdits
End Sub
 

ebs17

Well-known member
Local time
Today, 18:09
Joined
Feb 7, 2020
Messages
1,950
Code:
Class = Forms("frmStatus").strClass
If one evaluates strClass (a property of the form class?), it must be set purposefully beforehand. You don't see any of that. How you do that?
 

TajikBoy

Member
Local time
Today, 09:09
Joined
Mar 4, 2011
Messages
82
Why not just use:
Code:
Private Sub Form_Open(Cancel As Integer)

    Me.AllowEdits = False

    MsgBox "Allow Edits = " & Me.AllowEdits
   
End Sub
Form' editability depends on the users access level, hence the if statement to check
 

TajikBoy

Member
Local time
Today, 09:09
Joined
Mar 4, 2011
Messages
82
you put it on the Current event:
if "frmStatus" is the same form where you are putting the code:
Code:
Private Sub Form_Current()
Dim Class As String
Class = Forms("frmStatus").strClass & ""
MsgBox Class, vbOKOnly
If Class = "Read" Then
    Me.AllowEdits = False
Else
    Me.AllowEdits = True
End If
MsgBox "Allow Edits = " & Me.AllowEdits
End Sub
Hi ArnelGP,

frmStatus is my login form, which I hide after login and refer to the fields on it when/if needed, pretty sure there are other better ways but I prefer this way, got used to it more likely.....

Tried addition of your &"" and placed the code onCurrent, and form is still editable......
 

TajikBoy

Member
Local time
Today, 09:09
Joined
Mar 4, 2011
Messages
82
Code:
Class = Forms("frmStatus").strClass
If one evaluates strClass (a property of the form class?), it must be set purposefully beforehand. You don't see any of that. How you do that?
strClasss is an unbound text field on frmStatus form....
 

bob fitz

AWF VIP
Local time
Today, 17:09
Joined
May 23, 2011
Messages
4,727
Have you tried setting a breakpoint on the two lines:
Me.AllowEdits = False
Me.AllowEdits = True

just to check that one of them runs
 

TajikBoy

Member
Local time
Today, 09:09
Joined
Mar 4, 2011
Messages
82
Have you tried setting a breakpoint on the two lines:
Me.AllowEdits = False
Me.AllowEdits = True

just to check that one of them runs
if I put allowedits false without the user access level checking, form is not editable, so line works, not sure why the if block screws up things....
 

ebs17

Well-known member
Local time
Today, 18:09
Joined
Feb 7, 2020
Messages
1,950
Code:
If Forms("frmStatus").strClass = "Read" Then
   DoCmd.OpenForm "frmXY", , , , acFormReadOnly
Else
   DoCmd.OpenForm "frmXY", , , , acFormEdit
End If
If there are subforms, write protection must be set there separately.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:09
Joined
Feb 19, 2002
Messages
43,346
Take a look at my sample menu with simple security. It uses four security fields - Add, Edit, Delete, and View which are assigned to each user and also to each form. A small piece of code is placed in the BeforeUpdate, OnDeleteConfirm, Current, and BeforeInsert events. To determine if the action is allowed. There is no need to use the "allow" options since as other's mentioned, they will interfere with certain form operations.

 

TajikBoy

Member
Local time
Today, 09:09
Joined
Mar 4, 2011
Messages
82
Take a look at my sample menu with simple security. It uses four security fields - Add, Edit, Delete, and View which are assigned to each user and also to each form. A small piece of code is placed in the BeforeUpdate, OnDeleteConfirm, Current, and BeforeInsert events. To determine if the action is allowed. There is no need to use the "allow" options since as other's mentioned, they will interfere with certain form operations.

Thanks Pat, I'll have a look, I dont use Navigation option in Access, I implemented ribbons, I'll see if I can adopt your solution.....
 

Users who are viewing this thread

Top Bottom