I have a login form , i want to limit privileges of the user based on their type (e.g ; admin, encoder) wherein when the admin login, the mdi form will load and all the control buttons are accesible for him, while when the encoder login , only one button is enabled for him.

this is what i've gone so far

  If cmbposition.Text = "Administrative Head" Or cmbposition.Text = "HR Head" Or cmbposition.Text = "Team Leader" Or cmbposition.Text = "General Manager" Or cmbposition.Text = "Operation Head" Or cmbposition.Text = "Asst. Operation Head" Or cmbposition.Text = "Programmer" Then
                        MDIEBatch.Show()
                        Me.Hide()
                        txtuser.Clear()
                        txtpass.Clear()


                    ElseIf cmbposition.Text = "Entry" Or cmbposition.Text = "Verifier" Or cmbposition.Text = "MD Clipper" Or cmbposition.Text = "Encoder" Then
                        MDIEBatch.Show()
                        MDIEBatch.btnAddnewuser.Enabled = False
                        MDIEBatch.btnBatchForm.Enabled = False
                        MDIEBatch.btnhistory.Enabled = False
                        MDIEBatch.btnNewjob.Enabled = False
                        MDIEBatch.btnlogs.Enabled = False
                        MDIEBatch.btnJobStat.Enabled = False
                        MDIEBatch.btnMasterlist.Enabled = False 



                        Me.Hide()
                        txtuser.Clear()
                        txtpass.Clear()
                    Else
                        MsgBox("Either Username/Password is Incorrect", MsgBoxStyle.Exclamation, "Incorrect User!")
                        txtuser.Clear()
                        txtpass.Clear()
                    End If

unfortunately, it didn't work. all the controls are still enabled regardless of who logged in in the system.
can somebody help and tell me where i am wrong and suggest what should i do?

any help will be highly appreciated. thanks in advance ^_^

Set a Global variable for type of User at Login.
Initially set user_type = 0.
If the user_type is Admin set it to 1.
If the user_type is Encoder set it to 0.

When User / Admin are correctly logged in, then Check for User type.

If user_type == 1 Then
    Do whatever you want to do.
Else If user_type == 0 Then
    Disable whatever you want.
End If

This is just a rough idea.Hope you will figure out rest of coding.

Edited 2 Years Ago by Rahul47: mistakes

if you have read my code, that's what i actually did, but my problem lies in disabling a control button. seems like the code :

MDIEBatch.btnNewjob.Enabled = False
(and the other code like it) don't does what it suppose to do (which is to disable a button in the MDI form)

but anyway, thanks for ur suggestion

if you have read my code, that's what i actually did

What you are trying to do is Disable all buttons after immeadiately testing the condition. I need to test it, and figure out what you are missing.

My approach is like this.

While logging in.

If user='admin' Then
    user_type=1
    MDIBatch.show()
Else If user ='encoder' Then
    user_type=0
    MDIBatch.show()
End If

When MDI form is opened. At the load event of MDI.

If user_type=1 Then       // This is admin.
    Do whatever you want to do
ElseIf user_type=0 Then   // This is encoder.
    Disable all buttons. ( Me.button.enables= false )
End IF

Edited 2 Years Ago by Rahul47: changes

This question has already been answered. Start a new discussion instead.