Sub tom(a, b, c, d As Integer)
cbaru.Enabled = a
ccari.Enabled = b
cedit.Enabled = c
chapus.Enabled = d
End Sub
Sub kosong()
tini.Text = "": tnama.Text = ""
cbjab.Text = "": tpass.Text = ""
End Sub
Sub hidup()
tini.Enabled = 1: tnama.Enabled = 1
cbjab.Enabled = 1: tpass.Enabled = 1
End Sub
Sub mati()
tini.Enabled = 0: tnama.Enabled = 0
cbjab.Enabled = 0: tpass.Enabled = 0
End Sub
Sub simpen()
With Data1.Recordset
!inisial = tini.Text: !nmuser = tnama.Text
!jabatan = cbjab.Text: !Password = tpass.Text
End With
End Sub
Sub muncul()
With Data1.Recordset
tini.Text = !inisial: tnama.Text = !nmuser
cbjab.Text = !jabatan: tpass.Text = !Password
End With
End Sub
Private Sub cbaru_Click()
Select Case cbaru.Caption
Case "Baru": cbaru.Caption = "Simpan"
hidup
kosong
tom 1, 1, 0, 0
tini.SetFocus
Case "Simpan": cbaru.Caption = "Baru"
If tini.Text = "" Or tnama.Text = "" Then
MsgBox "Inisial & Nama Wajib diisi"
form_activate
Else
Data1.Recordset.AddNew
simpen
Data1.Recordset.Update
MsgBox "Data Tersimpan"
form_activate
End If
End Select
End Sub
Private Sub ccari_Click()
cari.Visible = True
tcari.Text = ""
tom 0, 0, 1, 1
tcari.SetFocus
End Sub
Private Sub cedit_Click()
Select Case cedit.Caption
Case "Edit": cedit.Caption = "Update"
hidup
tom 0, 0, 1, 0
tini.SetFocus
Case "Update": cedit.Caption = "Edit"
If tini.Text = "" Or tnama.Text = "" Then
MsgBox "Inisial & Nama Wajib diidi"
Else
Data1.Recordset.Edit
simpen
Data1.Recordset.Update
MsgBox "Data Berhasil Di Update"
kosong
mati
form_activate
End If
End Select
End Sub
Private Sub chapus_Click()
If Data1.Recordset.RecordCount > 0 Then
If MsgBox("Yakin mw diapuz ?", vbYesNo + vbQuestion, "Konfirmasi") = vbYes Then
Data1.Recordset.Delete
Data1.Recordset.MoveFirst
form_activate
Else
form_activate
End If
Else
MsgBox "data Kosong"
End If
End Sub
Private Sub form_activate()
mati
tom 1, 1, 0, 0
End Sub
Private Sub tcari_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 27: cari.Visible = False: form_activate
Case 13: Data1.Recordset.FindFirst "inisial= '" & tcari.Text & "' "
If Data1.Recordset.NoMatch Then
cari.Visible = False
form_activate
MsgBox "Data yang dicari tidak ditemukan"
Else
cari.Visible = False
tom 0, 0, 1, 1
muncul
End If
End Select
End Sub
Private Sub tini_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 27: form_activate: cbaru.Caption = "Baru"
Case 13: Data1.Recordset.FindFirst "inisial= '" & tini.Text & "' "
If Data1.Recordset.NoMatch Then
tnama.SetFocus
Else
muncul
hidup
tom 0, 0, 1, 1
End If
End Select
End Sub
Posting Komentar