Results 1 to 10 of 10

Thread: Different user how to view in different tab?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    Different user how to view in different tab?

    Dear All,

    I face some problem in my final year project. I have five different access level which is administrator(ADMIN), supervisor(0), user tab 1(1), user tab 2(2), user tab 3(3) and user tab 4(4). User tab 1 to 4 is from different department.

    When user tab 4 login, how can i direct this category of user to see the tab 4 interface instead of tab 1 interface? What method should and code should i use to do so?

    Please help this noob.Thank you all of you.

  2. #2
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Different user how to view in different tab?

    you could always group the users into the different departments, then when the user logs in, it checks to see which department the user is in and then displays the right tab to the user on login. i do something similar for when a user or admin logs into my app.

    As an example:
    In your backend database where you store the users, have three fields. one called username, another called password and the third called department.

    EG:
    username password department
    user1 pass1 1

    Thwn when the user goes to login, you would query the db to see which department the user is in:
    VB Code:
    1. Option Explicit
    2.  
    3. Dim strSQL As String
    4. Dim strUName As String
    5. Dim strPwd As String
    6.  
    7. Dim conn As ADODB.Connection
    8. Dim rs As ADODB.Recordset
    9.  
    10.     Set conn = New ADODB.Connection
    11.     Set rs = New ADODB.Recordset
    12.  
    13.     conn.CursorLocation = adUseClient
    14.     conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database.mdb;Persist Security Info=false"
    15.    
    16.     strSQL = "SELECT * "
    17.     strSQL = strSQL & "FROM MY_DB_TABLE "
    18.     strSQL = strSQL & "WHERE Username = '" & txtUsername.Text & "' "
    19.     strSQL = strSQL & "AND Password = '" & txtPassword.Text & "' "
    20.  
    21.     rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic
    22.  
    23.     If Not (rs.EOF) Then
    24.         strUName = rs.Fields("Username").Value
    25.         strPwd = rs.Fields("Password").Value
    26.     End If
    27.  
    28.     'DO THE CHECKING FOR THE DEPARTMENT HERE
    29.     If txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "1" Then
    30.     'show panel one here on login
    31. elseif txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "2" Then
    32.     'show panel two here on login
    33. elseif txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "3" Then
    34.     'show panel three here on login
    35. elseif txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "4" Then
    36.     'show panel four here on login
    37. end if
    38.  
    39. rs.close
    40. set rs = nothing
    41.  
    42. conn.close
    43. set conn = nothing
    44. end sub

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Different user how to view in different tab?

    We have a specific user table in which all user names are entered. There is a field in the table that we call "Staff_Level". In this field is an integer which represents their security level. When the program starts, we get the name of the logged in user, query the user table and store their staff level in a global integer.

    What they can, and can not do, through the entire program is completely dependent on what the staff level number is.

  4. #4
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Different user how to view in different tab?

    sample in post #2 (uses Access DB but you can change the connection to what ever DB you're using.)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    Re: Different user how to view in different tab?

    What if I use something like this?

    VB Code:
    1. Private Sub cmdOk_Click()
    2. .....
    3. If Int_Level = "ADMIN" Then
    4.             New_Btn.Enabled = True
    5.             NewComp_Btn.Enabled = True
    6.             ChangePwd_Btn.Enabled = True
    7.             SSTab.Tab = 0
    8.             txtCustID.SetFocus
    9.             cmdNew.Enabled = False
    10.             Add_Btn.Enabled = False
    11.             cmdDelete.Enabled = False
    12.             cmdUpdate.Enabled = False
    13.         ElseIf Int_Level = "0" Then
    14.              ChangePwd_Btn.Enabled = True
    15.              SSTab.Tab = 0
    16.              txtCustID.SetFocus
    17.              cmdNew.Enabled = False
    18.              Add_Btn.Enabled = True
    19.              cmdDelete.Enabled = True
    20.              cmdUpdate.Enabled = False
    21.         ElseIf Int_Level = "1" Then
    22.             New_Btn.Enabled = False
    23.             NewComp_Btn.Enabled = False
    24.             ChangePwd_Btn.Enabled = True
    25.             cmdNew.Enabled = False
    26.             SSTab.Tab = 0
    27.             txtCustID.SetFocus
    28.             Add_Btn.Enabled = False
    29.             cmdDelete.Enabled = False
    30.             cmdUpdate.Enabled = False
    31.         ElseIf Int_Level = "4" Then
    32.             SSTab.Tab = 3
    33.             txtDateRcv.SetFocus
    34.             txtReceiveBy = str_FullName
    35.             New_Btn.Enabled = False
    36.             NewComp_Btn.Enabled = False
    37.             ChangePwd_Btn.Enabled = True
    38.  
    39.          
    40.         End If
    41.  
    42. ....

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Different user how to view in different tab?

    Try it...does it work for you?

    On the surface, it looks fine.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    Re: Different user how to view in different tab?

    Yah,it looks fine to me.. I hope to use the method from you all because you all method quite interesting. However,i am so stupid ..not so understand the coding. Too bad... I am trying to

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Different user how to view in different tab?

    Quote Originally Posted by frimily
    Yah,it looks fine to me.. I hope to use the method from you all because you all method quite interesting. However,i am so stupid ..not so understand the coding. Too bad... I am trying to
    What don't you understand?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    19

    Re: Different user how to view in different tab?

    strSQL = strSQL & "FROM MY_DB_TABLE "

    ....

    'DO THE CHECKING FOR THE DEPARTMENT HERE
    If txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "1" Then
    ....

    Why use like that?
    May i know please?

  10. #10
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Different user how to view in different tab?

    Quote Originally Posted by frimily
    strSQL = strSQL & "FROM MY_DB_TABLE "

    ....

    'DO THE CHECKING FOR THE DEPARTMENT HERE
    If txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "1" Then
    ....

    Why use like that?
    May i know please?
    strSQL is an SQL statement to check your backend database. then
    If txtUsername.Text = strUName is to check to see if the input in txtUsername matches the database value (see if its there) and same for txtPassword.Text = strPwd. then rs.Fields("Department").Value tells VB which column in the database to check for the user level .Value = "1" would be user level one.

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