Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issues trying to make a form read only for some users 1

Status
Not open for further replies.

08211987

Programmer
Apr 20, 2012
187
0
0
US
I have a form that I want to limit who can edit any field on a form, one group can edit all and the other group cannot edit any field. I have tried opening the form read-only but it still allows me to edit the fields. (I know the dsfuserName() is working because I am using it for another purpose in the DB)
If dsfUserName() = "xxxxx" Then 'users who can edit
DoCmd.OpenForm "form_PSSA_Tracker_Update", , , "ID = " & IntID, acFormEdit
Else
DoCmd.OpenForm "form_PSSA_Tracker_Update", , , "ID = " & IntID, acFormReadOnly
End If

I also tried it in the Form_Current() event by using the AllowEdits property like below and it also allows me to edit:
If dsfUserName() = "xxxxx" Then 'users who can edit
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If

An ideas what I am doing wrong?
Thanks!
 
I'd try the Load or Open event instead of the Current.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I've moved it to the On Load event and it sill is allowing me to edit, is the syntax correct for setting the AllowEdits property?
Me.AllowEdits = True

Thanks!
 
The syntax is correct, but you can simplify to

Me.allowedits = (dsfUserName() = "xxxxx")

By chance are you confusing additions with edits. You can still add/edit a new record.
 
That's a good point and I like the simplification. I will have to also take additions into account but in this case they are only edits but it is still allowing me to edit. Shouldn't the acFormEdit and acFormReadOnly also work. That would seem the easiest.
Thanks!

 
can you error check just to be sure
Msgbox dsfUserName()
before you if check
 
and yes acformreadonly should work fine. There must be something else going on, that you are not seeing. Any of the methods described should work.
 
Are you asking if the value of dsfUserName() is what I am expecting in order for it to now allow the edits? Yes I did and it still allows the updates. Shouldn't the Readonly on open do the trick?
Thanks.
 
Yes it should all work. In the on load, on current, or calling it as acreadonly. Something else must be going on. Any other code in the form that could be setting it back to allow edits.
 
You were absolutely right, MajP! I was requerying some combobox fields to get updated values for the lists and also setting a field value to a new value. Apparently by making any updates to the form fields it must reset the property. I tested both the Read-Only and the AllowEits and they do both work.

Thanks so much, now maybe I can get something done! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top