Form Petugas "Perpustakaan Sederhana"


Listingnya Nih, Tapi Jangan Lupa Buat Dulu Database dan Field-Fieldnya sesuai dengan Form yang diatas, dan Nama Object di Formnya juga jangan lupa disesuaikan kawan.



Sub aktif()
Dim h As Control
For Each h In Me
If TypeOf h Is TextBox Then h.Enabled = True
Next
End Sub

Sub bersih()
Dim h As Control
For Each h In Me
If TypeOf h Is TextBox Then h.Text = ""
If TypeOf h Is ComboBox Then h.Text = ""
Next
End Sub

Sub non()
Dim h As Control
For Each h In Me
If TypeOf h Is TextBox Then h.Enabled = False
Next
End Sub

Sub tampil()
With Adodc1.Recordset
        tkd_petugas = !kd_petugas
        tnm_petugas = !nm_petugas
End With
End Sub

Private Sub ccancel_Click()
h = MsgBox("Batalkan?", vbYesNo + vbQuestion, "Perpustakaan Bhendy | Konfirmasi")
If h = vbYes Then
   bersih
End If
End Sub

Private Sub cclose_Click()
h = MsgBox("Quit this application??", vbYesNo + vbQuestion, " Perpustakaan Bhendy | Konfirmasi ")
If h = vbYes Then
   Unload Me
End If
End Sub

Private Sub cdelete_Click()
If tkd_petugas.Text = "" Or tnm_petugas.Text = "" Then
MsgBox "Masukan Data yang Akan Di Hapus Terlebih Dahulu !!"
Else
h = MsgBox("Hapus Data Petugas??", vbYesNo + vbQuestion, " Perpustakaan Bhendy | Konfirmasi ")
If h = vbYes Then
   Adodc1.Recordset.Delete
   MsgBox "Data Telah Dihapus!!!", vbOKOnly + vbInformation, " Perpustakaan Bhendy | Informasi"
   bersih
End If
End If
End Sub

Private Sub cedit_Click()
If tkd_petugas <> "" Then
    If cedit.Caption = "&EDIT" Then
    aktif
    cedit.Caption = "UPDATE"
        Else
            With Adodc1.Recordset
                !kd_petugas = tkd_petugas
                !nm_petugas = tnm_petugas
                .Update
            End With
        bersih
        cedit.Caption = "&EDIT"
    End If
Else
MsgBox "Tidak Ada data Yang Di Edit", vbOKOnly + vbInformation, " Perpustakaan Bhendy | Informasi"
End If
End Sub

Private Sub cfirst_Click()
On Error Resume Next
Adodc1.Recordset.MoveFirst
tampil
End Sub

Private Sub clast_Click()
On Error Resume Next
Adodc1.Recordset.MoveLast
tampil
End Sub

Private Sub cnew_Click()
aktif
bersih
tkd_petugas.SetFocus
End Sub

Private Sub cnext_Click()
On Error Resume Next
If Adodc1.Recordset.EOF Then
MsgBox " Anda Berada di Akhir Record !!"
Else
Adodc1.Recordset.MoveNext
tampil
End If
End Sub

Private Sub cprev_Click()
On Error Resume Next
If Adodc1.Recordset.BOF Then
   MsgBox "Anda Berada Di Awal Record !!"
Else
   Adodc1.Recordset.MovePrevious
   tampil
End If
End Sub

Private Sub csave_Click()
Adodc1.RecordSource = "select * from tblpetugas"
Adodc1.Refresh
If tkd_petugas.Text = "" Or tnm_petugas.Text = "" Then
   MsgBox "Data Belum Lengkap!!!", vbOKOnly + vbCritical, " Perpustakaan Bhendy | Informasi"
Else
   With Adodc1.Recordset
        .AddNew
        !kd_petugas = tkd_petugas.Text
        !nm_petugas = tnm_petugas
        .Update
        MsgBox "Data Sudah Disimpan!!!", vbOKOnly + vbInformation, " Perpustakaan Bhendy | Informasi"
        bersih
        non
   End With
   DataGrid1.Refresh
End If
End Sub

Private Sub DataGrid1_Click()
tampil
End Sub

Private Sub Form_Load()
bersih
non

Adodc1.Visible = False
Adodc1.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\perpustakaan.mdb"
Adodc1.RecordSource = "select * from tblpetugas"
Adodc1.Refresh
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Right(Label1.Caption, Len(Label1.Caption) - 1) & Left(Label1.Caption, 1)
End Sub

Private Sub tkd_petugas_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii))) ‘Huruf Kapital
If KeyAscii = 13 Then
   Adodc1.RecordSource = "select * from tblpetugas where kd_petugas = '" & tkd_petugas.Text & "'"
   Adodc1.Refresh
   If Adodc1.Recordset.EOF = False Then
           MsgBox "Kode sudah ada"
           bersih
           tkd_petugas.SetFocus
   Else
           tkd_petugas.Enabled = False
           tnm_petugas.SetFocus
   End If
End If
End Sub

Share this

Related Posts

Previous
Next Post »