Ok here's what i want to do.
I woul like to disable the toolbar and menubar in my main form
depending on the usertype that was logged in.
My dbase field is UserType and record type can only be
User and Admin (Depends on the registration).
When a user log in which is a "User" type, toolbar and menubar is disabled.
If it is an admin type, they are enabled.
Oh, the user type is also displayed on my statusbar ("panel(2)").
Code for Main (form_load)
Private Sub Form_Load()
If StatusBar.Panels(2).Text = User Then
Toolbar1.Enabled = False
Else
Toolbar1.Enabled = True
End If
End Sub
For the login form:
Private Sub cmdLogin_Click()
Dim User As String
Dim CurrentPosition As String
passattemp = passattemp + 1
If txtUser.Text = "" And txtPass.Text = "" Then
MsgBox "Data required, please enter a valid username and password!", vbInformation, "Log-in Error"
txtUser.Text = ""
txtPass.Text = ""
txtUser.SetFocus
Else
Set db = New ADODB.Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\Database.mdb"
Set rs = New ADODB.Recordset
rs.Open "select * from Users where UserName = '" & txtUser & "'", db, adOpenStatic, adLockOptimistic
If Not rs.EOF Then
If txtPass.Text = rs!Password Then
MsgBox "Welcome to The Provincial Capitol Payroll System!", vbInformation, "Log-in Form"
User = cWords(txtUser.Text)
CurrentPosition = rs.Fields("UserType")
With Form2
.StatusBar.Panels(2).Text = User
End With
Unload Me
Form2.Show
Else
MsgBox "Password Incorrect. Please enter a valid password!" & vbCrLf & " Attempt left " & 3 - passattemp & "", vbExclamation, "Log-in Form"
txtPass.Text = ""
txtPass.SetFocus
Set rs = Nothing
End If
Else
MsgBox "This user does not exist. Access denied!" & vbCrLf & " Attempt left " & 3 - passattemp & "", vbExclamation, "Log In Error"
txtUser.Text = ""
txtPass.Text = ""
txtUser.SetFocus
End If
If passattemp = 3 Then
MsgBox "You are not an authorized user. Program will now Terminate", vbCritical, "Log In Error"
End
End If
End If
End Sub