Results 1 to 2 of 2

Thread: Menu Items Restrictions

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    1

    Angry Menu Items Restrictions

    Hi everybody,

    I am keeping <user id> and the <user group code> in a table named users. There is another table named 'Res_menus' to keep the <user group code> and the restricted Menu items. I have created a menu in the first form of my application with all the related menu items in the system. Menu name is similar to the field <restricted menu items> in the 'Res_menus' table. When a user logs into the system i need to disable menu items that is defined in 'Res_menus' for that particular <user group code>. Reference must be taken from the 'Res_menus' table If a user logs in to the system i can find the group code he is belonging to and from the 'Res_menus' the menus that shoul disable to that particular user.
    Can i do a this type of a thing with VB6. please help me to do this with some example codes.


    Susith.
    susith

  2. #2
    New Member
    Join Date
    Jul 2002
    Location
    Bradford
    Posts
    9

    Thumbs up Helping Hand

    Hi Susith,

    Like many things in VB, what you want is very easy to do

    The following code uses a Hard Coded list rather than a database, so just replace those elements of the code.

    Option Explicit
    Private sUserList(1 To 2, 1 To 3) As String

    Private Sub Form_Load()
    Dim oMenu As Menu
    Dim iCounter As Integer, iUser As Integer

    'User logged on (1 or 2)
    iUser = 1

    'Set up User1's list
    sUserList(1, 1) = "mnu1"
    sUserList(1, 2) = "mnu2"
    sUserList(1, 3) = "mnu4"

    'Set up User2's list
    sUserList(2, 1) = "mnu2"
    sUserList(2, 2) = "mnu3"
    sUserList(2, 3) = "mnu4"

    'Check each menu on this form
    For Each oMenu In frmUserLogon
    'Check all excluded menu's for the current user
    For iCounter = 1 To 3
    'Check if Menu Name and item on User's exclude list match
    If sUserList(iUser, iCounter) = oMenu.Name Then
    'If they do, disable the menu option
    oMenu.Enabled = False
    End If
    Next 'iCounter
    Next 'oMenu
    End Sub

    Hope this has been of some help to you. Good luck
    Last edited by MonkeyCode; Jul 12th, 2002 at 08:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width