gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
I have code that I successfully run for one of my forms "On Open". I am trying to modify this for another form where the code is run when I click a button on the form
I want to run the same code (this checks a table to see if the user has permissions)
when I click Button command270. If it finds a match I want it to change a fields setting
Digit_1.Enabled = False
Digit_1.Locked = True
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 add a new supplier"
End If
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: Form_Open" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occurred!"
Resume Error_Handler_Exit
End Sub
I want to run the same code (this checks a table to see if the user has permissions)
when I click Button command270. If it finds a match I want it to change a fields setting
Digit_1.Enabled = False
Digit_1.Locked = True