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

                    ElseIf cmbposition.Text = "Entry" Or cmbposition.Text = "Verifier" Or cmbposition.Text = "MD Clipper" Or cmbposition.Text = "Encoder" Then
                        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 

                        MsgBox("Either Username/Password is Incorrect", MsgBoxStyle.Exclamation, "Incorrect User!")
                    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 ^_^

Recommended Answers

All 4 Replies

Member Avatar for Rahul47

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.

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

Member Avatar for Rahul47

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
Else If user ='encoder' Then
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

thanks rahul47 it works!

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.