Hi,
I have a UserId, Pwd and Dept. in the login form. After user has successfully login, user will directly go to FrmMain. While Admin user should be directly go to the other form, FrmMenu. My problem is with the Admin user. Any idea?
this is my code,
------------------------------------------------
Public UserType As Integer
Private Sub CmdOK_Click()
On Error GoTo Err_CmdOK_Click
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
If IsNull([UserId]) Or IsNull([Pwd]) Then
MsgBox "You must enter both user id and password."
DoCmd.GoToControl "UserId"
Else
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Select tblUserLogin.*
FROM tblUserLogin WHERE
(tblUserLogin.User_Id='" & (Forms!
[FrmLogin]![UserId]) & "') "
If (StrComp(Forms![FrmLogin]![Pwd], rst
("Password", 1) <> 0) Then
MsgBox "Wrong Password. Please re-enter !!"
DoCmd.GoToControl "Pwd"
Else
Me.Visible = False
DoCmd.OpenForm "FrmMain"
End If
End If
Exit_CmdOK_Click:
Exit Sub
Err_CmdOK_Click:
MsgBox Err.Description
Resume Exit_CmdOK_Click
End Sub
------------------------------------------------
thanx in advance..
I have a UserId, Pwd and Dept. in the login form. After user has successfully login, user will directly go to FrmMain. While Admin user should be directly go to the other form, FrmMenu. My problem is with the Admin user. Any idea?
this is my code,
------------------------------------------------
Public UserType As Integer
Private Sub CmdOK_Click()
On Error GoTo Err_CmdOK_Click
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
If IsNull([UserId]) Or IsNull([Pwd]) Then
MsgBox "You must enter both user id and password."
DoCmd.GoToControl "UserId"
Else
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Select tblUserLogin.*
FROM tblUserLogin WHERE
(tblUserLogin.User_Id='" & (Forms!
[FrmLogin]![UserId]) & "') "
If (StrComp(Forms![FrmLogin]![Pwd], rst
("Password", 1) <> 0) Then
MsgBox "Wrong Password. Please re-enter !!"
DoCmd.GoToControl "Pwd"
Else
Me.Visible = False
DoCmd.OpenForm "FrmMain"
End If
End If
Exit_CmdOK_Click:
Exit Sub
Err_CmdOK_Click:
MsgBox Err.Description
Resume Exit_CmdOK_Click
End Sub
------------------------------------------------
thanx in advance..