Jumat, 07 Januari 2011

FORM LAPORAN

Rancangan Formnya





Tabel Tool :


Kode Programnya :
Option Explicit

Private koneksi As ADODB.Connection


Private Function konek() As Boolean
    On Error GoTo out
        Set koneksi = New ADODB.Connection
        koneksi.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DbSekolah.mdb;Persist Security Info=False"
        koneksi.CursorLocation = adUseClient
        konek = True
out:
End Function




Private Sub CariNama_Click()
Adodc1.Recordset.Filter = "Nama ='" & TxtNama & "'"
End Sub


Private Sub CariOP_Click()
Adodc1.Recordset.Filter = "Operator='" & TxtOperaotor & "'"
End Sub


Private Sub CariTgl_Click()
Adodc1.Recordset.Filter = "Tanggal='" & DTPicker1.Value & "'"
End Sub


Private Sub CmdCari_Click()
If Adodc1.Recordset.RecordCount <= 0 Then Exit Sub
     Adodc1.Recordset.MoveFirst
     Adodc1.Recordset.Find "NIS='" & TxtCari.Text & "'"
End Sub


Private Sub CmdCetak_Click()
DataReportPembayaran.Show
End Sub


Private Sub CmdHapus_Click()
Dim X As String
X = MsgBox(("Anda Yakin data ingin di hapus?"), vbYesNo + vbCritical)
If X = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
DataGrid1.ReBind
DataGrid1.Refresh
MsgBox "Data  telah di Hapus!", vbInformation + vbOKOnly = vbIgnore
End If
End Sub


Private Sub CmdRefresh_Click()
Adodc1.Refresh
DataGrid1.Refresh
End Sub


Private Sub Form_Load()
If Not konek() Then
        MsgBox "Gak bisa terhubung ke database!", vbCritical
        End
    End If
    Adodc1.ConnectionString = koneksi.ConnectionString
    Adodc1.RecordSource = "Pembayaran"
    Set DataGrid1.DataSource = Adodc1
End Sub


Private Sub TxtCari_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call CmdCari_Click
End If
End Sub

Tidak ada komentar:

Posting Komentar