VERSION 5.00
Begin VB.Form frmLoginForm 
   Appearance      =   0  'Flat
   BackColor       =   &H00FFC0FF&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   1860
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   4125
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   1860
   ScaleWidth      =   4125
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.PictureBox Picture1 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFC0C0&
      ForeColor       =   &H80000008&
      Height          =   1815
      Left            =   0
      ScaleHeight     =   1785
      ScaleWidth      =   4065
      TabIndex        =   0
      Top             =   0
      Width           =   4095
      Begin VB.CommandButton cmdExit 
         BackColor       =   &H00FFC0FF&
         Caption         =   "&Exit"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1440
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   960
         Width           =   1095
      End
      Begin VB.TextBox txtPassWord 
         Appearance      =   0  'Flat
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         IMEMode         =   3  'DISABLE
         Left            =   1440
         MaxLength       =   50
         PasswordChar    =   "*"
         TabIndex        =   2
         Top             =   600
         Width           =   2295
      End
      Begin VB.TextBox txtusername 
         Appearance      =   0  'Flat
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   1440
         MaxLength       =   50
         TabIndex        =   1
         Top             =   240
         Width           =   2295
      End
      Begin VB.CommandButton cmdLogin 
         BackColor       =   &H00FFC0FF&
         Caption         =   "&Log in"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2640
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   960
         Width           =   1095
      End
      Begin VB.Label lbltext 
         BackColor       =   &H00FFC0C0&
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   7
         Top             =   1440
         Width           =   3855
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         Caption         =   "Password"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   225
         Left            =   120
         TabIndex        =   6
         Top             =   570
         Width           =   870
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         Caption         =   "User Name"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   225
         Left            =   120
         TabIndex        =   5
         Top             =   270
         Width           =   945
      End
   End
End
Attribute VB_Name = "frmLoginForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim flg, eflg As Boolean

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdLogin_Click()
login
End Sub
Private Sub login()
If eflg = True Then
If txtusername.Text = "" Or txtPassWord.Text = "" Then Exit Sub
If MsgBox("This will be your new username and password" & vbCrLf & "Save the login details ? ", vbInformation + vbYesNo, "Message") = vbYes Then
lbltext.Caption = ""
cn.Execute "insert into logintable values (1000,'" & txtusername.Text & "','" & txtPassWord.Text & "')"
Unload Me
MainForm.Show
End If
Exit Sub
End If
Set rs = New ADODB.Recordset
rs.Open "select * from LoginTable ", cn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
While Not rs.EOF
If rs!UserName = txtusername.Text And rs!Password = txtPassWord.Text Then
Unload Me
MainForm.Show
flg = True
Else
flg = False
End If
rs.MoveNext
Wend
Else

End If
If flg = False Then
MsgBox "PassWord not Correct", vbInformation, "Message"
End If
End Sub

Private Sub Form_Activate()
txtusername.SetFocus
End Sub

Private Sub Form_Load()
flg = True
eflg = False
Set rs = New ADODB.Recordset
rs.Open "select * from LoginTable ", cn, adOpenKeyset, adLockOptimistic
If Not rs.RecordCount > 0 Then
lbltext.Caption = "Enter your new username and login "
eflg = True
End If
 
End Sub
 

Private Sub txtPassWord_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
login
End If
End Sub
 

Private Sub txtusername_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
login
End If
End Sub
