gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
I have code that checks a table to see if the Current User should be able to open a form
What I want to do is modify this code so that it checks the table, like its doing, but now I want it to populate an unbound filed on the form so that it reads the user name and if they have rights.
So if it finds the user name and the form name the unbound text field (Text293) would = "Joe.Smith has Modify rights"
assuming the users name was Joe.Smith
Else it would say "Joe.Smith Does not have Modify rights"
Is this possible?
Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Error_Handler
If Nz(DLookup("UserName", "tbl_Users", _
"[Object_Name]='" & Me.Name & "' AND [UserName]='" & CurrentUser() & "'"), "") = "" Then
Cancel = True
MsgBox "You are not authorized to Edit/Modify Commodities"
End If
Error_Handler_Exit:
On Error Resume Next
Exit Sub
What I want to do is modify this code so that it checks the table, like its doing, but now I want it to populate an unbound filed on the form so that it reads the user name and if they have rights.
So if it finds the user name and the form name the unbound text field (Text293) would = "Joe.Smith has Modify rights"
assuming the users name was Joe.Smith
Else it would say "Joe.Smith Does not have Modify rights"
Is this possible?