Results 1 to 10 of 10

Thread: [RESOLVED] Problem In Sorting Recods, And Counting Them

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2015
    Posts
    103

    Resolved [RESOLVED] Problem In Sorting Recods, And Counting Them

    So this is probably my last question for this final project (probably, sort of). So please help me guys, do your best.

    I have records here like this in "absen" table in mysql Name:  absen.JPG
Views: 323
Size:  33.5 KB

    and I wrote this (probably bad) code in transaction form :

    Code:
    Dim countval As Integer
    Dim countlem As Integer
    
    tahun = Right(DTPicker1, 4)
    hari = Left(DTPicker1, 2)
    bulan = Mid(DTPicker1, 4, 2)
    galtang = tahun & "-" & bulan & "-" & hari
    tahun2 = Right(DTPicker2, 4)
    hari2 = Left(DTPicker2, 2)
    bulan2 = Mid(DTPicker2, 4, 2)
    galtang2 = tahun & "-" & bulan & "-" & hari
    
    Call koneksi
    hitung = "select count(*) from absen where NIP ='" & cnip & "' and status ='absen keluar' and tglabsen between '" & galtang & "' and '" & galtang2 & "'"
    rsabsen.Open hitung, KON, adOpenForwardOnly, adLockReadOnly
    
    If Not rsabsen.EOF Then
    
       countval = rsabsen(0).Value
       tjumlahabsen = countval
       gaji = Val(tjumlahabsen.Text) * Val(tgaji.Text)
       rsabsen.Close
       lembur = "select sum(lmbr) from absen where NIP ='" & cnip & "' and status ='absen keluar' and tglabsen between '" & galtang & "' and '" & galtang2 & "'"
       rsabsen.Open lembur, KON, adOpenForwardOnly, adLockReadOnly
       
       If Not rsabsen(0).Value <= 0 Then
       
       countlem = rsabsen(0).Value
       tjumlahjamlembur = countlem
       ttunjangan = rsabsen(0).Value * Val(txtlemburperjam.Text)
       ttotalgaji = Val(gaji.Text) + Val(ttunjangan.Text)
       
       Else
       tjumlahjamlembur = 0
       End If
       bsimpan.Enabled = True
    Else
    MsgBox "Data tidak ditemukan"
    End If
    DTPicker1.Enabled = False
    DTPicker2.Enabled = False
    grid2.Enabled = False
    End Sub
    that code above is to sort the records in "absen" table, according to NIP, status, and tglabsen that the user set between 2 dtpicker in transaction form (as you can see, i use string manipulation to turn the dates format from dd/mm/yyy to yyyy-mm-dd), and returns the amount of records that mysql catch. I set the date from 1 august 2017 to 31 august 2017, and the code returned 1 (it returns 1 to tjumlahabsen textbox). Is there anything wrong with them? any suggestion? thanks in advance

    here is the transaction form

    Name:  transaksi.jpg
Views: 255
Size:  15.5 KB

    the code is written as click even for "OK" button
    Last edited by xboner; Aug 9th, 2017 at 07:18 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width