I am trying to use an IF statement to enable/disable command buttons; however, I get the following error message "Run Time Error '424': Object Required". The "cmdDeptStoresMC.Enabled=True" is highlighted in yellow when I run the code. Please assist. Below is my code:
Sub Check_AccessRights()
Dim X As String
Dim Y As String
X = EssVCell(Null, "Year Total", "MC", "Business Type", "Accounts", "Departments")
Y = EssVCell(Null, "Year Total", "OR", "Business Type", "Accounts", "Departments")
If X = "#No Access" Then
cmdDeptStoresMC.Enabled = False
cmdRetailStoresMC.Enabled = False
Else
cmdDeptStoresMC.Enabled = True
cmdRetailStoresMC.Enabled = True
End If
If Y = "#No Access" Then
cmdDeptStoresOR.Enabled = False
cmdRetailStoresOR.Enabled = False
Else
cmdDeptStoresOR.Enabled = True
cmdRetailStoresOR.Enabled = True
End If
End Sub