Anda di halaman 1dari 3

Membuat Modul Koneksi

Public Koneksi As New ADODB.Connection


Public rspetugas As ADODB.Recordset

Public Sub BukaDB()


Set Koneksi = New ADODB.Connection
Set rspetugas = New ADODB.Recordset
Set RSB = New ADODB.Recordset
Koneksi.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=perpusprojek;Initial
Catalog=db_perpus"
End Sub

Form Menu Utama


Sub terkunci()
mnlogin.Enabled = True
mnlogout.Enabled = False
End Sub

Private Sub Form_Load()


Call terkunci
End Sub

Private Sub mnkeluar_Click()


End
End Sub

Private Sub mnlogin_Click()


FormLogin.Show vbModal
End Sub

Private Sub mnlogout_Click()


Call terkunci
End Sub

Private Sub mnpetugas_Click()


FormMasterPetugas.Show
End Sub
Form Login

Sub Terbuka()
FormMenuUtama.mnlogin.Enabled = False
FormMenuUtama.mnlogout.Enabled = True
End Sub

Private Sub Command2_Click()


Unload Me
End Sub

Private Sub Form_Activate()


Text1 = ""
Text2 = ""
Text1.SetFocus
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
Text2.SetFocus
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub

Function CariData()
Call BukaDB
rspetugas.Open "Select * From petugas where kodePetugas='" & Text1 & "'", Koneksi
End Function
Private Sub Command1_Click()
Call BukaDB
rspetugas.Open "Select * from petugas where kodepetugas ='" & Text1 & "' and
passwordpetugas='" & Text2 & "'", Koneksi
If rspetugas.EOF Then
MsgBox "KodePetugas atau Password Salah!"
Text1.SetFocus
Else
Unload Me
FormMenuUtama.Show
Call Terbuka
End If
End Sub

Anda mungkin juga menyukai