me.allowedits

TajikBoy

Member
Local time
Today, 13:43
Joined
Mar 4, 2011
Messages
83
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 !
 
Try in the OnOpen event or in the OnCurrent event
 
Keep in mind that setting the AllowEdits property to False will still allow users to ADD new records and DELETE existing records
 
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
 
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
 
Why not just use:
Code:
Private Sub Form_Open(Cancel As Integer)

    Me.AllowEdits = False

    MsgBox "Allow Edits = " & Me.AllowEdits
    
End Sub
 
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
 
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?
 
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
 
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......
 
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....
 
Have you tried setting a breakpoint on the two lines:
Me.AllowEdits = False
Me.AllowEdits = True

just to check that one of them runs
 
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....
 
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.
 
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.

 
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

Back
Top Bottom