Private Sub LoginDulu() ‘kode program hak akses
Dim halo As String ‘deklarasi variable halo
Dim Cnn As New ADODB.Connection ‘deklarasi variable Cnn
Dim Rc As New ADODB.Recordset ‘deklarasi variable Rc
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Magistra utama.mdb;Persist Security Info=False" ‘membuka koneksi database Magistra utama.mdb
Rc.CursorLocation = adUseClient
halo = "select * from Tlogin where username = '" & Text1.Text & "'" ‘nilai valiabel halo
Rc.Open halo, Cnn, adOpenKeyset, adLockOptimistic ‘membuka nilai halo yang berisi rumus untuk perintah query login
If Rc.RecordCount = 0 Then ‘jika tidak ada record
MsgBox "Username tidak terdaftar" ‘muncul pesan User tidak terdaftar
Text1 = ""
Text1.SetFocus
Exit Sub
End If
If Rc.Fields(1) <> Text2.Text Then ‘jika kolom password salah muncul pesan Password salah mau coba lagi?
pesan = MsgBox("Pasword Salah. Mau Coba Lagi?", vbYesNo, "Peringatan")
If pesan = vbYes Then
Text2 = ""
Text2.SetFocus
End If
Else
FrmMenu.Show
FrmLogin.Hide
End If
End Sub
Sub Wassalam() ‘perintah wassalam
pesan = MsgBox("Are you sure to Exit The Program???", vbOKCancel, "Peringatan")
If pesan = vbOK Then
End
Else
Exit Sub
End If
End Sub
Private Sub CmdClose_Click()
Wassalam ‘memanggil wassalam
End Sub
Private Sub CmdCancel_Click()
Text1 = "" : Text2 = "" : Text1.SetFocus
End Sub
Private Sub CmdOk_Click()
Call LoginDulu ‘memanggil perintah LoginDulu
End Sub
Private Sub Form_Load()
FrmLogin.Height = 5475
FrmLogin.Width = 7485
End Sub
Sub Buka()
Text1.Visible = True : Text2.Visible = True : Text1.SetFocus
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Call LoginDulu ‘jika text2 di Enter maka memanggil perintah LoginDUlu
End Sub
0 komentar:
Posting Komentar