Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub mngajibulanan_Click()
- X = MsgBox("Anda yakin Cetak Laporan Gaji Bulanan?", vbQuestion + vbYesNo, "Konfirmasi Cetak..")
- If X = vbYes Then
- 'bagian deklarasi
- Dim xlapp As Excel.Application
- Dim xlwb As Excel.Workbook
- Dim xlsheet As Excel.Worksheet
- 'koneksi ke tabel
- Set rs = New ADODB.Recordset
- rs.CursorLocation = adUseClient
- rs.Open "select * from carigaji", db, adOpenStatic, adLockReadOnly
- 'bagian eksekusi
- Set xlapp = New Excel.Application
- Set xlwb = xlapp.Workbooks.Add
- Set xlsheet = xlwb.Worksheets(1)
- xlapp.Visible = True
- 'buat judul tabel
- With xlsheet
- .Cells(1, 2).Value = "LAPORAN PENGGAJIAN PT.ABC"
- .Cells(3, 1).ColumnWidth = 12
- .Cells(3, 1).Value = "NIP"
- .Cells(3, 2).ColumnWidth = 20
- .Cells(3, 2).Value = "NAMA PEGAWAI"
- .Cells(3, 3).ColumnWidth = 11
- .Cells(3, 3).Value = "GOLONGAN"
- .Cells(3, 4).ColumnWidth = 11
- .Cells(3, 4).Value = "GAJI POKOK"
- .Cells(3, 5).Value = "TJ. ANAK"
- .Cells(3, 6).ColumnWidth = 15
- .Cells(3, 6).Value = "TJ. PERKAWINAN"
- .Cells(3, 7).ColumnWidth = 11
- .Cells(3, 7).Value = "GAJI KOTOR"
- .Cells(3, 8).ColumnWidth = 10.3
- .Cells(3, 8).Value = "PAJAK"
- .Cells(3, 9).ColumnWidth = 11
- .Cells(3, 9).Value = "GAJI BERSIH"
- End With
- 'BAGIAN PENAMPILAN DATA
- br = 4
- totalgaji = 0
- With xlsheet
- rs.MoveFirst
- For i = 1 To rs.RecordCount
- .Cells(br, 1) = rs!NIP
- .Cells(br, 2) = rs!NAMA
- .Cells(br, 3) = rs!GOL
- .Cells(br, 4) = rs!GAJIPOKOK
- .Cells(br, 5) = rs!TJANAK
- .Cells(br, 6) = rs!TJKAWIN
- .Cells(br, 7) = rs!GAJIKOTOR
- .Cells(br, 8) = rs!PAJAK
- .Cells(br, 9) = rs!GAJIBERSIH
- totalgaji = totalgaji + rs!GAJIBERSIH
- rs.MoveNext
- br = br + 1
- Next
- .Cells(br, 8) = "TOTAL GAJI"
- .Cells(br, 9) = totalgaji
- End With
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement