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.
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:
Option Explicit
Dim strSQL As String
Dim strUName As String
Dim strPwd As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.CursorLocation = adUseClient
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database.mdb;Persist Security Info=false"
strSQL = "SELECT * "
strSQL = strSQL & "FROM MY_DB_TABLE "
strSQL = strSQL & "WHERE Username = '" & txtUsername.Text & "' "
strSQL = strSQL & "AND Password = '" & txtPassword.Text & "' "
rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic
If Not (rs.EOF) Then
strUName = rs.Fields("Username").Value
strPwd = rs.Fields("Password").Value
End If
'DO THE CHECKING FOR THE DEPARTMENT HERE
If txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "1" Then
'show panel one here on login
elseif txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "2" Then
'show panel two here on login
elseif txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "3" Then
'show panel three here on login
elseif txtUsername.Text = strUName And txtPassword.Text = strPwd And rs.Fields("Department").Value = "4" Then
'show panel four here on login
end if
rs.close
set rs = nothing
conn.close
set conn = nothing
end sub
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.
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.)
Re: Different user how to view in different tab?
What if I use something like this?
VB Code:
Private Sub cmdOk_Click()
.....
If Int_Level = "ADMIN" Then
New_Btn.Enabled = True
NewComp_Btn.Enabled = True
ChangePwd_Btn.Enabled = True
SSTab.Tab = 0
txtCustID.SetFocus
cmdNew.Enabled = False
Add_Btn.Enabled = False
cmdDelete.Enabled = False
cmdUpdate.Enabled = False
ElseIf Int_Level = "0" Then
ChangePwd_Btn.Enabled = True
SSTab.Tab = 0
txtCustID.SetFocus
cmdNew.Enabled = False
Add_Btn.Enabled = True
cmdDelete.Enabled = True
cmdUpdate.Enabled = False
ElseIf Int_Level = "1" Then
New_Btn.Enabled = False
NewComp_Btn.Enabled = False
ChangePwd_Btn.Enabled = True
cmdNew.Enabled = False
SSTab.Tab = 0
txtCustID.SetFocus
Add_Btn.Enabled = False
cmdDelete.Enabled = False
cmdUpdate.Enabled = False
ElseIf Int_Level = "4" Then
SSTab.Tab = 3
txtDateRcv.SetFocus
txtReceiveBy = str_FullName
New_Btn.Enabled = False
NewComp_Btn.Enabled = False
ChangePwd_Btn.Enabled = True
End If
....
Re: Different user how to view in different tab?
Try it...does it work for you?
On the surface, it looks fine.
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
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?
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?
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.