• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

User Access

sn152

Member
Good Evening All,

I have a work book with 2 userforms in it (Login and Activities). I have another workbook which has the list of usernames and passwords. Now I have to give access to these users so that they should be able to login with their user id, password and their role and once they log in they should be able to view the Activities userform.

Please help me in this.
Thanks in advance... :)
 

Attachments

  • User Access.xlsx
    11.3 KB · Views: 23
  • Draft (2) (1).xlsm
    14.7 KB · Views: 16
Check with it, there might be some bug on previous attachment.
 

Attachments

  • Draft (2) (1)_Password2.xlsm
    37.5 KB · Views: 21
Hi Deepak,
Thank you for helping me. The first file you posted is the one which I want. But it is working only when I select the Role as "Team Leader". How can I give access for other roles? Request you to help me...

Thanks!
 
Hi Deepak,
Thank you for helping me. The first file you posted is the one which I want. But it is working only when I select the Role as "Team Leader". How can I give access for other roles? Request you to help me...

Thanks!

Ya! i realize the same later so that 2nd file was posted later.
Pls check with that!!!
 
Yes I checked that file :). But the form design should look like how it is in the 1st file. Is there any way where we can fix the first file?

Thanks!
 
Hi sn152
Pls go with attached file check & let me know if any further changes required.
 

Attachments

  • Draft (3) (1)_Password4.xlsm
    48.9 KB · Views: 41
Hi Deepak,

This is perfect. This works fine. Thank you so much for helping me... I really appreciate your help..

Thanks again.
 
Hi Deepak,

I apologize for not posting the question here.

I tried this code,
If r = 2 Then
Manager_Login.Show
Else
Activities.Show
End If
But it is not working. If i enter the id and password of a team leader and select the role of team manager and click on submit, it shows msgboc "access denied". But when i click ok on the msgbox, it shows the activities userform.

But what I wanted is if I enter username, password and select the role of team manager then it should show Manager_Login userform. For all other roles it should show Activities userform.

Please help me.

Thanks!
 
Hi,

As current approach is based where all these three username,password,role needs to match as per UserAccess Sheet DB.Unless the all three get match login form no other userform will load.

So, It's not possible...
" If i enter the id and password of a team leader and select the role of team manager and click on submit, it shows msgboc "access denied". But when i click ok on the msgbox, it shows the activities userform."

Manager_Login userform only show when team manager login,password,role get submitted else on sucessful validation of login,password,role Activities form will load.

Code:
Private Sub CommandButton1_Click()
Dim ul As Worksheet
Dim UserName As String, Password As String
Dim mUser As Variant, r As Integer, op As Integer

UserName = Login.NameTextBox.Value
Password = Login.pwdTextBox.Value

Select Case True
    Case Me.tlOptionButton1
        op = 1
    Case Me.tmOptionButton2
        op = 2
    Case Me.sdmOptionButton3
        op = 3
    Case Me.dgmOptionButton4
        op = 4
    Case Me.gmOptionButton5
        op = 5
Case Else
        MsgBox "Pls select your role!!!", vbExclamation
        Exit Sub
End Select

Set ul = Sheets("User Access")
    mUser = Application.Match(Val(UserName), ul.Columns(2), 0)
                If IsError(mUser) Then
                MsgBox "Invalid UserName", vbCritical
                Exit Sub
                Else
                End If
If UCase(ul.Cells(mUser, 4).Value) = UCase("Team Leader") Then r = 1
If UCase(ul.Cells(mUser, 4).Value) = UCase("Team Manager") Then r = 2
If UCase(ul.Cells(mUser, 4).Value) = UCase("Service Delivery Manager") Then r = 3
If UCase(ul.Cells(mUser, 4).Value) = UCase("Deputy General Manager") Then r = 4
If UCase(ul.Cells(mUser, 4).Value) = UCase("General Manager") Then r = 5
   
    If ul.Cells(mUser, 2).Value = Val(UserName) And _
            UCase(ul.Cells(mUser, 3).Value) = UCase(Password) And r = op Then
            Unload Login
            Application.ScreenUpdating = False
            Application.ScreenUpdating = True
            MsgBox "Access Granted", vbInformation
            If r = 2 Then
                Manager_Login.Show
            Else
                Activities.Show
            End If
          Else
            MsgBox "Access Denied", vbCritical
            Login.NameTextBox.SetFocus
    End If
   
End Sub

If it not respond what you want then pls explain bit more to assist you.
 
Hi Deepak,

I already tried the above code. But what I want is, when I enter the username, password and select the role of team manager, then "manager_login" userform should be shown. If I enter the username, password and select the role of team leader or any other role except team manager, then the "activities" userform should be shown. Is this possible? Please help me.

Thanks!
 
Check this.

Code:
If ul.Cells(mUser, 2).Value = Val(UserName) And _
            UCase(ul.Cells(mUser, 3).Value) = UCase(Password)
 
Oops.

Hope this would help!!

Code:
 If ul.Cells(mUser, 2).Value = Val(UserName) And _
            UCase(ul.Cells(mUser, 3).Value) = UCase(Password) Then
            Unload Login
            MsgBox "Access Granted", vbInformation
            If op = 2 Then
                Manager_Login.Show
            Else
                Activities.Show
            End If
          Else
            MsgBox "Access Denied", vbCritical
            Login.NameTextBox.SetFocus
    End If
 
Hi Deepak,

I have a user form called Manager_Login. A manager logs in to this tool using the "Login" userform with their username, password and by selecting the role (These details are on the sheet (User access). Upon successful login of a manager, the "Manager_Login" user form is shown.


Now on this form, the userid and Emp Name of the manager who logged should automatically appear on the "label11" and "label10". And automatically the combobox1 should also be filled with the reporting team leaders of that particular manager. This data is available on the sheet "Lookup".
Also when a team leader's name is selected from the combobox1, "label6, label7 and label8" should automatically be filled with the date shown in the "Lookup" sheet under the column, "EWS, PKT, and One On One" for that selected Team leader.


It would be great if you could help me with this.


Thanks in advance!
 

Attachments

  • Manager Login.xlsm
    37.7 KB · Views: 8
Hi Deepak,

If I want to add few more managers and team leaders can I add it in the "Lookup" sheet under the speciafic columns? Please advice
 
You have entered data in Cells B16, D16 and D18 in lookup sheet. Can I delete those and add managers and team leaders name?
 
Back
Top