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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Only Privileges

Status
Not open for further replies.

SpeedStick

Technical User
May 24, 2007
37
US
I have form that I want some users to have 'read only' privileges. I have table that defines which users have what privileges. Can someone help me develop the solution so that certain user have 'read only' privileges on a form?
 
You could use a function like this:
Code:
Private Sub DisableForm(frm As Form)
 
  With frm
    .AllowEdits = False
    .AllowAdditions = False
    .AllowDeletions = False
  End With
 
End Sub

Set a global variable when the user logs on and call the function from the Load event of the form that you want to protect from the users:

Code:
  If gstrUserLevel = USERLEVEL Then  
    DisableForm Me
  End If




Geoff Franklin
 
Thank you for your response.

I am not fimiliar with Global values how and where do you set one up?

Thank you,

Scott

 
How does a person test to see if a global variable is working?
 
I have been trying to work through for a solution and I do not seem to be getting it. Any assistance would be appreciated.

I set the following as a "DisableForm" global variable in the logon form.
Public DisableForm As String

Then set the following code to Form_Load the following code. StrAccess is the field in the table that list the rights for the user.
If StrAccess = User Then
DisableForm Me
End If

With the code above I am getting a Compile Error - Expected Procedure not variable.


On the form side
I am wishing to disable this is my code.
Private Sub frm_tab(frm As Form)
With frm
.AllowEdits = False
.AllowAdditions = False
.AllowDeletions = False
End With
End Sub


 
In the database window, select modules and click new and save it as whatever name you want the module to be

Define a global variable in this module.
Code:
Public sUser as string

and also put your Disable form sub here as well.

You can then store the current username in the sUser variable at whatever event you want since it's a global variable.

Then on the form open event, check the sUser variable against your table. If the user isn't on the table, then call the Disable form sub.
 
put your Disable form sub here as well.

All I'd add to Joe's explanation is that you'll need to change my code and declare the function as Public rather than as Private so that the forms can see it.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top