Kamis, 16 Januari 2014

Menghitung Sum & Count sebuah tabel dengan adodc

Private Sub CariTotal()
adototal.RecordSource = "select sum(debet) as vTotDeb,sum(kredit) as vTotKre from jurnal where day(tanggal)>= " & Day(CDate(TxtTglAwal.Value)) & " and day(tanggal)<= " & Day(CDate(TxtTglAkhir.Value)) & " and Month(tanggal)>= " & Month(CDate(TxtTglAwal.Value)) & " And Month(tanggal)<= " & Month(CDate(TxtTglAkhir.Value)) & " and Year(tanggal)>=" & Year(CDate(TxtTglAwal.Value)) & " and Year(tanggal)<=" & Year(CDate(TxtTglAkhir.Value)) & ""
adototal.Refresh
lblTotalDebet.Caption = adototal.Recordset!vTotDeb
lblTotalKredit.Caption = adototal.Recordset!vTotKre
End Sub

Private Sub cari_salah()
adoQbnrSlh.RecordSource = "select count(*) as hasil_slh from QBenarSalah where hasil='SALAH'"
adoQbnrSlh.Refresh
txtsalah.Text = adoQbnrSlh.Recordset!hasil_slh
End Sub

Private Sub cari_benar()
adoQbnrSlh.RecordSource = "select count(*) as hasil_bnr from QBenarSalah where hasil='BENAR'"
adoQbnrSlh.Refresh
txtbenar.Text = adoQbnrSlh.Recordset!hasil_bnr
End Sub