Description
This is a common situation where one needs to restrict some user for accessing some menus and some operations like AddNew Record, Edit / Change Record, Delete Record etc. it is required for almost every application that runs in a multi-user environment.
To do this you need some tables to hold data and a form to manipulate that data according to your policy.
Follow the three steps given below to accomplish this task.
Step 1:
Create the following tables in your database or in a new database:



Step 2 :
Make a form like given below (Codes attached):
Step 3
Add the following code into your mdiForm's or Form contains menus Load events.
Public Sub LoadMenu()
Try
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim ds1 As New DataSet
Dim strSql As String
Dim nParentId As Integer
Dim i As Integer
Dim tsm As ToolStripMenuItem
For Each tsm In frmMain.MenuStrip.Items
strSql = "select Menus.MenuID,Menus.MenuName from UserRights " _
& "Inner Join Menus On Menus.MenuID=UserRights.MenuID " _
& "Where userID=" & intUserId & " And Menus.MenuName='" & tsm.Name.ToString & "' and
Menus.programid=" & intProgramID
Comments
Join the conversation! Your thoughts help the community grow.