Untuk membuat Form Login, anda harus membuat Form Baru, caranya anda Klik Project - Add Form
1. Ubah nama form Menjadi : FormLogin
2. Caption : Form Login
Buat Design Form Seperti dibawah ini :
Masukan Coding dibawah ini :
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Activate()
Text2.Enabled = False
End Sub
Sub Form_Load()
Call BukaDB
Text1.MaxLength = 6
Text2.MaxLength = 10
Text2.PasswordChar = "X"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Call BukaDB
Call CariData
If RSAdmin.EOF Then
MsgBox "Admin Tidak Terdeteksi, Coba lagi"
Text1 = ""
Else
Text1.Enabled = False
Text2.Enabled = True
Text2.SetFocus
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
CmdLogin.SetFocus
End If
End Sub
Function CariData()
Call BukaDB
RSAdmin.Open "Select * From Admin where kodeAdmin='" & Text1 & "'", koneksi
End Function
Private Sub CmdLogin_Click()
Dim KodeAdmin As String
Dim NamaAdmin As String
Call BukaDB
RSAdmin.Open "Select * from Admin where kodeAdmin ='" & Text1 & "' and passwordAdmin='" & Text2 & "'", koneksi
If RSAdmin.EOF Then
MsgBox "Password Salah, Coba Lagi!"
Text2 = ""
Text2.SetFocus
Else
Unload Me
FormMenuUtama.Show
End If
End Sub
Catatan :
Jangan Lupa pada Form Menu Utama ketika pada menu editor klik Login, anda harus memasukan koding
Form Login Show
Klik Run atau F5
Setelah FormMenuUtama show, Silahkan ke File dan Klik Login
Masukan Kode Admin : ADM001 (Kemudian Tekan ENTER)
Password Admin (Kemudian Tekan ENTER)
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Activate()
Text2.Enabled = False
End Sub
Sub Form_Load()
Call BukaDB
Text1.MaxLength = 6
Text2.MaxLength = 10
Text2.PasswordChar = "X"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Call BukaDB
Call CariData
If RSAdmin.EOF Then
MsgBox "Admin Tidak Terdeteksi, Coba lagi"
Text1 = ""
Else
Text1.Enabled = False
Text2.Enabled = True
Text2.SetFocus
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
CmdLogin.SetFocus
End If
End Sub
Function CariData()
Call BukaDB
RSAdmin.Open "Select * From Admin where kodeAdmin='" & Text1 & "'", koneksi
End Function
Private Sub CmdLogin_Click()
Dim KodeAdmin As String
Dim NamaAdmin As String
Call BukaDB
RSAdmin.Open "Select * from Admin where kodeAdmin ='" & Text1 & "' and passwordAdmin='" & Text2 & "'", koneksi
If RSAdmin.EOF Then
MsgBox "Password Salah, Coba Lagi!"
Text2 = ""
Text2.SetFocus
Else
Unload Me
FormMenuUtama.Show
End If
End Sub
Catatan :
Jangan Lupa pada Form Menu Utama ketika pada menu editor klik Login, anda harus memasukan koding
Form Login Show
Klik Run atau F5
Setelah FormMenuUtama show, Silahkan ke File dan Klik Login
Masukan Kode Admin : ADM001 (Kemudian Tekan ENTER)
Password Admin (Kemudian Tekan ENTER)
0 comments:
Post a Comment