Help with allowedits

L

Lloyd

I am trying to disable edits, additions, deletions based on a users rights.
The code runs, but is not working. I have tried the code in the forms
current and form load events but both fail to lock down the form.

Private Sub Form_Load()

If Forms![frmrights]![userrights] = "readonly" Then
MsgBox "CaseUpdate Form Read Only"

Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End If
End Sub
 
B

boblarson

Are you sure that Forms![frmrights]![userrights] is really returning
"readonly?" You could set a breakpoint at the point where it is checking the
value and see if the code actually goes in there.
--
Bob Larson

Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________
 
L

Lloyd

yes I tested that and it is.

I found the following. I have the form on a tab. its the first tab. when
the code runs I can still enter data, but if I switch to the second tab (chg
page), and then switch back, then everything works as it should. I dont get
why I would have to do that. I also tried a me.refresh but that didnt help.

boblarson said:
Are you siure that Forms![frmrights]![userrights] is really returning
"readonly?" You could set a breakpoint at the point where it is checking the
value and see if the code actually goes in there.
--
Bob Larson

Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________


Lloyd said:
I am trying to disable edits, additions, deletions based on a users rights.
The code runs, but is not working. I have tried the code in the forms
current and form load events but both fail to lock down the form.

Private Sub Form_Load()

If Forms![frmrights]![userrights] = "readonly" Then
MsgBox "CaseUpdate Form Read Only"

Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End If
End Sub
 
A

Allen Browne

Lloyd, you have something else that is dirtying the form.

For example, if you assign a value to a bound control (or directly a field)
in Form_Load or Form_Open or Form_Current, in the an event of the control
that first gets focus, the form now has uncommitted edits (i.e. it is
dirty.) Microsoft decided it was better to let you complete the entry rather
than leave you stuck, unable to complete the entry and get out of the
situation you are now in. Therefore Access ignores the form's AllowEdits
property if the record has been dirtied programmatically.

Once you click on the next tab (which contains a subform?) the record is
saved, and so now the form's AllowEdits property is respected.

It actually makes no sense to dirty the record in Form_Open, Form_Load, or
Form_Current. Just because a user visits a record does not mean that the
record needs to be altered.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Lloyd said:
yes I tested that and it is.

I found the following. I have the form on a tab. its the first tab.
when
the code runs I can still enter data, but if I switch to the second tab
(chg
page), and then switch back, then everything works as it should. I dont
get
why I would have to do that. I also tried a me.refresh but that didnt
help.

boblarson said:
Are you siure that Forms![frmrights]![userrights] is really returning
"readonly?" You could set a breakpoint at the point where it is checking
the
value and see if the code actually goes in there.
--
Bob Larson

Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________


Lloyd said:
I am trying to disable edits, additions, deletions based on a users
rights.
The code runs, but is not working. I have tried the code in the forms
current and form load events but both fail to lock down the form.

Private Sub Form_Load()

If Forms![frmrights]![userrights] = "readonly" Then
MsgBox "CaseUpdate Form Read Only"

Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AllowEdits 5
AllowEdits=False issue 3
Help needed with AllowEdits logic 3
Save when editing a record 2
Mandatory Fields 4
.AllowEdits 1
Locking a record via a form 2
Lock records against edits 3

Top