Hi All,

I want to add some admin privaliges to my program, its simple enough, when the user is logged in as admin certain buttons are enabled, when the user is logged in as anyone else, these buttons are disabled.

Please see my code below

Private Sub MRMMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If Me.Text = "Meeting Room Manager - ADMIN" Then
            btnNewUsers.Enabled = True
            btnCurrentBookings.Enabled = True
        Else
            btnNewUsers.Enabled = False
            btnCurrentBookings.Enabled = False
        End If
    End Sub

the problem I have is that the buttons are disabled even when logged in as ADMIN.

I dont understand why this wont work it seems simple enough, can anyone see what I have done wrong.

Thanks very much

John

1.'assume that the 'admins' or any user is populated in a combobox aor any suitable control the it is as follows
Private Sub MRMMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
2.

3.
If Me.selectedItem = "Meeting Room Manager - ADMIN" Then
4.
btnNewUsers.Enabled = True
5.
btnCurrentBookings.Enabled = True
6.
Else
7.
btnNewUsers.Enabled = False
8.
btnCurrentBookings.Enabled = False
9.
End If
10.
End Sub

Hi mogaka,

I think I fixed it, I need more users in the database to test the program but it looks like its sorted, please see my working code below

Private Sub MRMMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If Me.Text <> "Meeting Room Manager - ADMIN" Then
            btnNewUsers.Enabled = True
            btnCurrentBookings.Enabled = True
        Else
            btnNewUsers.Enabled = False
            btnCurrentBookings.Enabled = False
        End If
    End Sub

Thanks for your reply

John

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.