VERSION 5.00
Begin VB.Form frmLogin 
   Caption         =   "Login"
   ClientHeight    =   3000
   ClientLeft      =   120
   ClientTop       =   420
   ClientWidth     =   5010
   LinkTopic       =   "Form1"
   ScaleHeight     =   3000
   ScaleWidth      =   5010
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdCancel 
      Caption         =   "Cancel"
      Height          =   615
      Left            =   2880
      TabIndex        =   3
      Top             =   1920
      Width           =   1215
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "Login"
      Height          =   615
      Left            =   1080
      TabIndex        =   2
      Top             =   1920
      Width           =   1215
   End
   Begin VB.TextBox txtPassword 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2040
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1320
      Width           =   2055
   End
   Begin VB.TextBox txtUserName 
      Height          =   375
      Left            =   2040
      TabIndex        =   0
      Top             =   480
      Width           =   2055
   End
   Begin VB.Label Label2 
      Caption         =   "Password"
      Height          =   375
      Left            =   720
      TabIndex        =   5
      Top             =   1320
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "Username"
      Height          =   375
      Left            =   720
      TabIndex        =   4
      Top             =   480
      Width           =   855
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim glbPosition As String

Private Sub cmdCancel_Click()
End
End Sub

Private Sub cmdOK_Click()
If txtUserName = "" Then
MsgBox "¡ÃØ³ÒãÊè Username", vbExclamation + vbOKOnly, "á¨é§àµ×Í¹"
Exit Sub
End If

If txtPassword = "" Then
MsgBox "¡ÃØ³ÒãÊè Password", vbExclamation + vbOKOnly, "á¨é§àµ×Í¹"
Exit Sub
End If

'------------------------------------------------------------------------------------------------------------------
    Dim rs As New ADODB.Recordset

    rs.Open "SELECT * FROM tbl_user WHERE Username = '" & txtUserName & "'", conn, adOpenStatic, adLockReadOnly
    If rs.RecordCount <> 0 Then
        If txtPassword = rs!Password Then
  glbPosition = rs![Position]
            MsgBox glbPosition, vbInformation + vbOKOnly, "ÂÔ¹´ÕµéÍ¹ÃÑº"
            'Remove msgbox above then call a form to be load if login is succesful!
            frmOn.Show
            Unload Me
        Else
            MsgBox "Invalid Password, try again!", , "Login"
        End If
    Else
        MsgBox "Invalid Login, try again!", , "Login"
        Call clear
    End If
    rs.Close
    Set rs = Nothing
End Sub


Sub clear()
txtUserName.Text = ""
txtPassword.Text = ""

End Sub

Private Sub Command3_Click()
frmUser.Show vbModal

End Sub

Private Sub Form_Load()
Dbase
End Sub
