Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 45

Dim Rs As DAO.

Recordset

Dim bulan_romawi, Urut

Option Compare Database

Private Sub alamat_AfterUpdate()

On Error Resume Next

alamat.Requery

'refresh

End Sub

Private Sub cmdCari_Click()

On Error Resume Next

On Error GoTo Err_btnSearch_Click

Dim strCriteria As String

Dim rst As DAO.Recordset

Dim strSearch As String

strSearch = InputBox("Pencarian", "DLB Express", "Masukkan nomer AWB")

Set rst = Form_invoice_outbound_detail.RecordsetClone

strCriteria = "[no_awb] like '*" & strSearch & "*'"

rst.FindFirst strCriteria
If Not rst.NoMatch Then

If Not rst.EOF Then Form_invoice_outbound_detail.Bookmark = rst.Bookmark

Else ' If no Match

MsgBox "Nomer AWB itu tidak ada!", vbInformation, "Info"

End If

rst.Close

Exit_btnSearch_Click:

Set rst = Nothing

Exit Sub

Err_btnSearch_Click:

MsgBox err.Description

Resume Exit_btnSearch_Click

End Sub

Private Sub cmdCariFaktur_Click()

On Error Resume Next

On Error GoTo Err_btnSearch_Click

Dim strCriteria As String

Dim rst As DAO.Recordset


Dim strSearch As String

strSearch = InputBox("Pencarian", "DLB Express", "Masukkan nomer AWB")

Set rst = Form_invoice_outbound_detail.RecordsetClone

strCriteria = "[no_faktur] like '*" & strSearch & "*'"

rst.FindFirst strCriteria

If Not rst.NoMatch Then

If Not rst.EOF Then Form_invoice_outbound_detail.Bookmark = rst.Bookmark

Else ' If no Match

MsgBox "Nomer Faktur " & strSearch & " tidak ada!", vbInformation, "Info"

End If

rst.Close

Exit_btnSearch_Click:

Set rst = Nothing

Exit Sub

Err_btnSearch_Click:

MsgBox err.Description

Resume Exit_btnSearch_Click

End Sub
Private Sub cmdCariKode_Click()

On Error Resume Next

On Error GoTo Err_btnSearch_Click

Dim strCriteria As String

Dim rst As DAO.Recordset

Dim strSearch As String

strSearch = InputBox("Pencarian", "DLB Express", "Masukkan Kodenya")

Set rst = Form_invoice_outbound_detail.RecordsetClone

strCriteria = "[kode] like '*" & strSearch & "*'"

rst.FindFirst strCriteria

If Not rst.NoMatch Then

If Not rst.EOF Then Form_invoice_outbound_detail.Bookmark = rst.Bookmark

Else ' If no Match

MsgBox "Kode itu tidak ada!", vbInformation, "Info"

End If

rst.Close

Exit_btnSearch_Click:

Set rst = Nothing

Exit Sub
Err_btnSearch_Click:

MsgBox err.Description

Resume Exit_btnSearch_Click

End Sub

Private Sub cmdCariTanggal_Click()

On Error Resume Next

On Error GoTo Err_btnSearch_Click

Dim strCriteria As String

Dim rst As DAO.Recordset

Dim strSearch As String

strSearch = InputBox("Pencarian", "DLB Express", "Masukkan Tanggal")

Set rst = Form_invoice_outbound_detail.RecordsetClone

strCriteria = "[pengirim_tgl] = #" & Format(strSearch, "mm/dd/yyyy") & "#"

rst.FindFirst strCriteria

If Not rst.NoMatch Then

If Not rst.EOF Then Form_invoice_outbound_detail.Bookmark = rst.Bookmark

Else ' If no Match

MsgBox "Tanggal itu tidak ada!", vbInformation, "Info"


End If

rst.Close

Exit_btnSearch_Click:

Set rst = Nothing

Exit Sub

Err_btnSearch_Click:

MsgBox err.Description

Resume Exit_btnSearch_Click

End Sub

Private Sub cmdPecahTanggal_Click()

On Error Resume Next

DoCmd.OpenForm "lgn_pecah_awb"

Form_lgn_pecah_awb.Caption = "Outbound Pertanggal"

End Sub

Private Sub cmdDataBaru_Click()

On Error Resume Next


Select Case bulan

Case 1

bulan_romawi = "I"

Case 2

bulan_romawi = "II"

Case 3

bulan_romawi = "III"

Case 4

bulan_romawi = "IV"

Case 5

bulan_romawi = "V"

Case 6

bulan_romawi = "VI"

Case 7

bulan_romawi = "VII"

Case 8

bulan_romawi = "VIII"
Case 9

bulan_romawi = "IX"

Case 10

bulan_romawi = "X"

Case 11

bulan_romawi = "XI"

Case 12

bulan_romawi = "XII"

End Select

'Set rs = CurrentDb.OpenRecordset("select * from invoice_outbound")

'If rs.RecordCount > 0 Then rs.MoveLast

'urut = rs.RecordCount + 1

'combo1.SetFocus

'DoCmd.GoToRecord , , acNewRec

'no_invoice = String(4 - Len(urut), "0") & urut & "/DLB-DPS/INV-OUT/" & bulan_romawi & "/" & tahun

End Sub

Private Sub cmdCetakBalik_Click()


End Sub

Private Sub cmdCetakPODBalikDoc_Click()

On Error Resume Next

DoCmd.OpenReport "invoice_outbound_pod_balik_doc", acViewPreview, , "tipe='doc'"

End Sub

Private Sub cmdCetakPODBalikNonDoc_Click()

On Error Resume Next

DoCmd.OpenReport "invoice_outbound_pod_balik_non_doc", acViewPreview

'DoCmd.Close acReport, "invoice_outbound_pod_balik_non_doc_header"

'DoCmd.OpenReport "invoice_outbound_pod_balik_doc", acViewPreview

End Sub

Private Sub cmdCetakFaktur_Click()

On Error Resume Next

Dim Rs As Recordset

Set Rs = CurrentDb.OpenRecordset("SELECT min(minpt) AS awal, max(maxpt) AS akhir FROM (SELECT


Min(invoice_Outbound_detail.pengirim_tgl) AS minpt, Max(invoice_Outbound_detail.pengirim_tgl) AS
maxpt FROM invoice_Outbound_detail GROUP BY invoice_Outbound_detail.customer,
invoice_Outbound_detail.bulan, invoice_Outbound_detail.tahun, invoice_Outbound_detail.customer,
invoice_Outbound_detail.bulan, invoice_Outbound_detail.tahun HAVING
(((invoice_Outbound_detail.customer)='" & [Forms]![invoice_outbound]![Combo1] & "') AND
((invoice_Outbound_detail.bulan) Between " & [Forms]![invoice_outbound]![combo2] - 2 & " And " &
[Forms]![invoice_outbound]![combo2] & ") AND ((invoice_Outbound_detail.tahun)=" & [Forms]!
[invoice_outbound]![combo3] & "))) AS gab;")

DoCmd.OpenForm "perTanggalOutboundPilih"
With Form_perTanggalOutboundPilih

.dt = Rs!awal

.st = Rs!akhir

.Caption = "cetak no faktur Outbound pertanggal"

Form_perTanggalOutboundDetailPilih.RecordSource = "SELECT tblInvoiceOutboundDetail.*, * FROM


tblInvoiceOutboundDetail WHERE (((Format([pengirim_tgl],0)) Between Format([forms]!
[perTanggalOutboundPilih]![dt],0) And Format([forms]![perTanggalOutboundPilih]![st],0)));"

Form_perTanggalOutboundDetailPilih.Requery

Refresh

Form_perTanggalOutboundDetailPilih.OrderBy = True

Form_perTanggalOutboundDetailPilih.OrderBy = "pengirim_tgl, no_awb"

Dim Urut As Long

'Set Rs = CurrentDb.OpenRecordset("SELECT tblInvoiceOutboundDetail.*, * FROM


tblInvoiceOutboundDetail WHERE (((Format([pengirim_tgl],0)) Between Format([forms]!
[perTanggalOutboundPilih]![dt],0) And Format([forms]![perTanggalOutboundPilih]![st],0)));")

Set Rs = Form_perTanggalOutboundDetailPilih.RecordsetClone

With Rs

'If Not .EOF Then

.MoveFirst
Do Until .EOF

Urut = Urut + 1

.Edit

!nom = Urut

.Update

.MoveNext

Loop

'End If

.Close

End With

Form_perTanggalOutboundDetailPilih.Requery

Refresh

Form_perTanggalOutboundPilih.dt.SetFocus

End With

DoCmd.RunSQL "update invoice_outbound_temp set customer = combo1, bulan = combo2, tahun =


combo3"

DoCmd.Close acForm, "invoice_outbound"

End Sub
Private Sub cmdCetakPerTanggal_Click()

On Error Resume Next

Dim Rs As Recordset

'Set rs = CurrentDb.OpenRecordset("SELECT Min(invoice_outbound_detail.pengirim_tgl) AS minpt,


Max(invoice_outbound_detail.pengirim_tgl) AS maxpt FROM invoice_outbound_detail GROUP BY
invoice_outbound_detail.[bulan], invoice_outbound_detail.[tahun] HAVING (((invoice_outbound_detail.
[kabupaten])= '" & combo4 & "') AND ((invoice_outbound_detail.[bulan])= " & combo2 & ") AND
((invoice_outbound_detail.[tahun])= " & combo3 & "));")

Set Rs = CurrentDb.OpenRecordset("select min(pengirim_tgl) as minpt, max(pengirim_tgl) as maxpt


FROM invoice_outbound_detail GROUP BY customer, bulan, tahun having customer = '" & Combo1 & "'
and bulan= " & combo2 & " and tahun= " & combo3 & "")

DoCmd.OpenForm "pertanggal"

Form_pertanggal.dt = Rs!minpt

Form_pertanggal.st = Rs!maxpt

Form_pertanggal.Caption = "cetak outbound pertanggal"

End Sub

Private Sub cmdKeluar_Click()

On Error Resume Next

DoCmd.Close

DoCmd.SetWarnings False

'DoCmd.RunSQL "delete * from invoice_outbound"

End Sub

Private Sub cmdPecahAWB_Click()


On Error Resume Next

DoCmd.OpenForm "lgn_pecah_awb" ', , , , , acDialog, "outbound"

Form_lgn_pecah_awb.Caption = "outbound perawb"

End Sub

Private Sub cmdPecahBeban_Click()

On Error Resume Next

DoCmd.OpenForm "lgn_pecah_awb" ', , , , , acDialog, "outbound"

Form_lgn_pecah_awb.Caption = "outbound perbeban"

End Sub

Private Sub cmdPecahKode_Click()

On Error Resume Next

DoCmd.OpenForm "lgn_pecah_awb" ', , , , , acDialog, "outbound"

Form_lgn_pecah_awb.Caption = "outbound perkode"

End Sub

Private Sub cmdSimpanSebagaiPDF_Click()

On Error Resume Next

Set Application.Printer = Application.Printers("CutePDF Writer")

DoCmd.OpenReport "invoice_outbound"
'Now, set the Default Printer back to the way it was

Set Application.Printer = Nothing

'Application.DoCmd.OpenReport "invoice_outbound", acViewPreview, , , acWindowNormal

'Prompt and export in one line of code.

'Application.DoCmd.RunCommand acCmdExportRTF

End Sub

Private Sub cmdPODBelumBalik_Click()

DoCmd.OpenForm "pilihanCetak"

Forms!pilihanCetak.Caption = "outbound pod balik"

End Sub

Private Sub cmdTampilkan_Click()

On Error Resume Next

DoCmd.Maximize

'Bulan Romawi

Select Case combo2

Case 1

bulan_romawi = "I"

Case 2

bulan_romawi = "II"
Case 3

bulan_romawi = "III"

Case 4

bulan_romawi = "IV"

Case 5

bulan_romawi = "V"

Case 6

bulan_romawi = "VI"

Case 7

bulan_romawi = "VII"

Case 8

bulan_romawi = "VIII"

Case 9

bulan_romawi = "IX"

Case 10

bulan_romawi = "X"

Case 11

bulan_romawi = "XI"

Case 12

bulan_romawi = "XII"

End Select

Set Rs = Me.RecordsetClone

Dim strCriteria
strCriteria = "[customer] ='" & Combo1 & "' and [bulan] = " & combo2 & " and [tahun] = " & combo3 & ""

Rs.FindFirst strCriteria

If Not Rs.NoMatch Then

If Not Rs.EOF Then Me.Bookmark = Rs.Bookmark

Else

Rs.AddNew

Rs!customer = Combo1

Rs!bulan = combo2

Rs!tahun = combo3

Rs!no_invoice = "0000/DLB-DPS/INV-OUT/" & bulan_romawi & "/" & combo3

Rs!tgl_invoice = DateSerial((combo3), combo2 + 1, 0)

Rs.Update

End If

Rs.FindFirst strCriteria

If Not Rs.NoMatch Then

If Not Rs.EOF Then Me.Bookmark = Rs.Bookmark

End If

DoCmd.GoToControl "invoice_outbound_detail"
Dim sumber_data As String

If combo4 = "All" And combo5 <> "All" Then

If customer = "pt.tempo" Then

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound_detail where


customer= '" & Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and tipe = '" &
combo5 & "' and ypecah <=0 and ypecah <=0 and tipe <> 'city courier' order by pengirim_tgl, no_awb"

Else

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound_detail where


customer= '" & Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and tipe = '" &
combo5 & "' and ypecah <=0 and ypecah <=0 order by pengirim_tgl, no_awb"

End If

Set Rs = CurrentDb.OpenRecordset("SELECT * FROM invoice_outbound_detail where customer= '" &


Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and tipe = '" & combo5 & "' and
ypecah <=0 and tipe <> 'city courier' order by pengirim_tgl, no_awb") 'and ypecah <=0

If Rs.RecordCount = 0 Then

MsgBox "Tidak ada data!", vbInformation, "Info"

Else

Form_invoice_outbound_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

'Form_pertipe_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

End If

End If

If combo5 = "All" And combo4 <> "All" Then

End If
If combo4 = "All" And combo5 <> "All" Then

If customer = "pt.tempo" Then

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound_detail where


customer= '" & Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and kode = '" &
combo4 & "' and ypecah <=0 and ypecah <=0 and tipe <> 'city courier' order by pengirim_tgl, no_awb"

Else

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound_detail where


customer= '" & Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and kode = '" &
combo4 & "' and ypecah <=0 and ypecah <=0 order by pengirim_tgl, no_awb"

End If

Set Rs = CurrentDb.OpenRecordset("SELECT * FROM invoice_outbound_detail where customer= '" &


Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and kode = '" & combo4 & "' and
ypecah <=0 and tipe <> 'city courier' order by pengirim_tgl, no_awb") 'and ypecah <=0

If Rs.RecordCount = 0 Then

MsgBox "Tidak ada data!", vbInformation, "Info"

Else

Form_invoice_outbound_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

End If

End If

If combo4 = "All" And combo5 = "All" Then

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound_detail where


customer= '" & Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and (berat <> 0
or qty <> 0) order by pengirim_tgl, no_awb" 'and ypecah <=0

Set Rs = CurrentDb.OpenRecordset("SELECT * FROM invoice_outbound_detail where customer= '" &


Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and (berat <> 0 or qty <> 0)
order by pengirim_tgl, no_awb") 'and ypecah <=0
If Rs.RecordCount = 0 Then

MsgBox "Tidak ada data!", vbInformation, "Info"

Else

Form_invoice_outbound_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

End If

If customer = "pt.tempo" Then

Set Rs = CurrentDb.OpenRecordset("SELECT * FROM invoice_outbound_detail where customer= '" &


Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and ypecah <=0 and tipe <> 'city
courier' order by pengirim_tgl, no_awb") 'and ypecah <=0

Else

Set Rs = CurrentDb.OpenRecordset("SELECT * FROM invoice_outbound_detail where customer= '" &


Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and (berat <> 0 or qty <> 0)
order by pengirim_tgl, no_awb") 'and ypecah <=0

End If

If Rs.RecordCount = 0 Then

MsgBox "Tidak ada data!", vbInformation, "Info"

Else

Form_invoice_outbound_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

'Form_pertipe_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

End If

End If

If combo4 <> "All" And combo5 <> "All" Then

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound_detail where


customer= '" & Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and kode = '" &
combo4 & "' and tipe= '" & combo5 & "' and ypecah <=0 and ypecah <=0 and tipe <> 'city courier' order
by pengirim_tgl, no_awb"

Set Rs = CurrentDb.OpenRecordset("SELECT * FROM invoice_outbound_detail where customer= '" &


Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & " and kode = '" & combo4 & "' and
tipe= '" & combo5 & "' and ypecah <=0 and tipe <> 'city courier' order by pengirim_tgl, no_awb") 'and
ypecah <=0

If Rs.RecordCount = 0 Then

MsgBox "Tidak ada data!", vbInformation, "Info"

Else

Form_invoice_outbound_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

'Form_pertipe_detail.RecordSource = Form_invoice_outbound_detail.RecordSource

End If

End If

'Harga, Biaya Kirim dan Penomeran

Dim Urut As Long

Set Rs = CurrentDb.OpenRecordset("select * from invoice_outbound_detail where customer = '" &


Combo1 & "' and bulan = " & combo2 & " and tahun = " & combo3 & " order by pengirim_tgl, no_awb")

With Rs

'If Not .EOF Then

.MoveFirst

Do Until .EOF
'Urut = Urut + 1

.Edit

If !yKunciHarga = 0 Then

If Me.customer = "OUT ADEX" Then

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "customer = '" & !


customer & "' and tipe='" & Left(!tipe, 12) & "' and kode_daerah='" & !kode & "' and pick_up='" & !asal &
"'")

Else

If Form_invoice_outbound_detail.tipe = "Harga Kg / Port" Or Form_invoice_outbound_detail.tipe =


"Harga Kg / Door" Or Form_invoice_outbound_detail.tipe = "Harga Kg / Darat" Or
Form_invoice_outbound_detail.tipe = "Hand Carry" Or Form_invoice_outbound_detail.tipe = "Harga Kg /
City" Or Form_invoice_outbound_detail.tipe = "Harga Kg / Port ONS" Then

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "combo1=forms!


invoice_outbound!invoice_outbound_detail!customer and tipe='Harga Kg / Port' and kode_daerah='" & !
kode & "' and pick_up='" & !asal & "'")

Else

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "customer = '" & !


customer & "' and tipe='" & Left(!tipe, 12) & "' and kode_daerah='" & !kode & "' and pick_up = '" & !asal
& "'")

If customer = "pt. anugerah Pharmindo Lestari ( Return )" Then

With Form_invoice_outbound_detail

If .berat >= 3 Then

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "customer = '"


& !customer & "' and tipe='" & Left(!tipe, 12) & "' and kode_daerah='" & !kode & "'")

End If

End With

End If
End If

If Not IsNull(Forms!invoice_outbound!invoice_outbound_detail!tarif) Or Forms!invoice_outbound!


invoice_outbound_detail!tarif <> "" Then !yKunciHarga = True

If customer = "RUBIYAT" Then

Select Case !berat

Case Is <= 199

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "customer = '" & !


customer & "' and tipe='" & Left(!tipe, 12) & "' and kode_daerah='" & !kode & "' and pick_up='" & !asal &
"'")

Case 200 To 299

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "customer = '" & !


customer & "' and tipe='" & Left(!tipe, 12) & "' and kode_daerah='" & !kode & "' and pick_up='" & !asal &
"'") * 0.9

Case 300 To 499

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "customer = '" & !


customer & "' and tipe='" & Left(!tipe, 12) & "' and kode_daerah='" & !kode & "' and pick_up='" & !asal &
"'") * 0.85

Case Is >= 500

!tarif = DLookup("harga_per_kg", "customer_outbound_daftar_harga_detail", "customer = '" & !


customer & "' and tipe='" & Left(!tipe, 12) & "' and kode_daerah='" & !kode & "' and pick_up='" & !asal &
"'") * 0.8

End Select
End If

If Not IsNull(Forms!invoice_outbound!invoice_outbound_detail!tarif) Or Forms!invoice_outbound!


invoice_outbound_detail!tarif <> "" Then !yKunciHarga = True

End If

End If

Dim strKodee, strAsall

strKodee = Form_invoice_outbound_detail.kode

strAsall = Form_invoice_outbound_detail.asal

If Left(Form_invoice_outbound_detail.tipe, 7) = "outbound" Then

Form_invoice_outbound_detail.asal = strKodee

Form_invoice_outbound_detail.kode = strAsall

End If

'If !nom = 762 And !yKunciBiayaKirim = False Then

If !yKunciBiayaKirim = False Then

If customer = "PT G4S SECURITY" Then

If !tipe <> "doc" Then

!discount = (!berat * !tarif) * 0.1

Else

!discount = 0

End If
If !yKunciBiayaKirim = False Then

If IsNull(Rs!pengali) Or Rs!IsNull(pengali) Or Rs!pengali = "berat" Then

Rs!biaya_kirim = Nz(!berat * !tarif) - Nz(!discount) + Nz(!biaya_packing)

Else

Rs!biaya_kirim = Nz(!qty * !tarif) - Nz(!discount) + Nz(!biaya_packing)

End If

End If

End If

If !customer = "PT. Abacus BCA" Then

'If !tipe <> "City Courier" Then

!discount = (!berat * !tarif) * 0.1

'Else

'!discount = 0

'End If

If !yKunciBiayaKirim = False Then

If IsNull(Rs!pengali) Or Rs!IsNull(pengali) Or Rs!pengali = "berat" Then

Rs!biaya_kirim = Nz(!berat * !tarif) - Nz(!discount) + Nz(!biaya_packing)

Else

Rs!biaya_kirim = Nz(!qty * !tarif) - Nz(!discount) + Nz(!biaya_packing)

End If

End If

End If
If Rs!customer <> "PT G4S SECURITY" And Rs!customer <> "PT. Abacus BCA" Then

If right(Rs!tipe, 3) = "CBM" Then

If !yKunciBiayaKirim = False Then Rs!biaya_kirim = Nz(Left(Rs!tipe, Len(Rs!tipe) - 4) * Rs!tarif) +


Nz(Rs!biaya_packing) - Nz(Rs!discount)

Else

If !yKunciBiayaKirim = False Then

If IsNull(Rs!pengali) Or Rs!IsNull(pengali) Or Rs!pengali = "berat" Then

Rs!biaya_kirim = Nz(!berat * !tarif) - Nz(!discount) + Nz(!biaya_packing)

Else

Rs!biaya_kirim = Nz(!qty * !tarif) - Nz(!discount) + Nz(!biaya_packing)

End If

End If

End If

End If

If !yKunciBiayaKirim = False Then

If IsNull(Rs!pengali) Or Rs!IsNull(pengali) Or Rs!pengali = "berat" Then

Rs!biaya_kirim = Nz(!berat * !tarif) - Nz(!discount) + Nz(!biaya_packing)

Else

Rs!biaya_kirim = Nz(!qty * !tarif) - Nz(!discount) + Nz(!biaya_packing)

End If

End If

End If
.Update

.MoveNext

Loop

'Pengurutan

Form_invoice_outbound_detail.OrderByOn = True

Form_invoice_outbound_detail.OrderBy = "pengirim_tgl, no_awb"

penomeran

End With

Form_invoice_outbound_detail.Requery

Refresh

Form_invoice_outbound_detail.biaya_kirim_total.Requery

Dim total As Currency


Set Rs = CurrentDb.OpenRecordset("select * from invoice_outbound_detail where customer = '" &
Forms!invoice_outbound!customer & "' and bulan = " & Forms!invoice_outbound!combo2 & " and
tahun = " & Forms!invoice_outbound!combo3 & "")

While Not Rs.EOF

total = total + Nz(Rs!biaya_kirim)

Rs.MoveNext

Wend

Form_invoice_outbound.subtotal_invoice = total

If yPPN = True Then

If Forms!invoice_outbound!yClosing = 0 Then

ppn = subtotal_invoice * 0.01

Else

ppn = Left(subtotal_invoice, Len(subtotal_invoice) - 2)

End If

Form_invoice_outbound.total_invoice = Nz(Form_invoice_outbound.subtotal_invoice) +
Nz(Form_invoice_outbound.ppn)

Else

Form_invoice_outbound.total_invoice = Form_invoice_outbound.subtotal_invoice
End If

With Form_invoice_outbound_detail

.yKunciHargaAll = .yKunciHarga

End With

Perhitungan_Total

End Sub

Private Sub cmdUrutkanTglAWB_Click()

On Error Resume Next

cmdTampilkan_Click

Form_invoice_outbound_detail.OrderByOn = True

Form_invoice_outbound_detail.OrderBy = "pengirim_tgl, no_awb"

penomeran

End Sub

Private Sub combo1_DblClick(Cancel As Integer)

DoCmd.OpenForm "customer"

End Sub
Private Sub Command84_Click()

DoCmd.OpenQuery "qryInvoiceOutbound"

End Sub

Private Sub Command95_Click()

DoCmd.OpenQuery "qryInvoiceOutbound"

End Sub

Private Sub Command98_Click()

On Error Resume Next

Set Rs = Form_invoice_outbound_detail.RecordsetClone

Rs.MoveFirst

Do Until Rs.EOF

Rs.Edit

With Form_invoice_outbound_detail

If .yBalik = -1 Then

Rs!ida = Rs!id

Else

Rs!ida = 0

End If
End With

Rs.Update

Rs.MoveNext

Loop

Form_invoice_outbound_detail.Requery

Refresh

End Sub

Private Sub discount_AfterUpdate()

On Error Resume Next

If yPPN = True Then

total_after_discount_label.Visible = True

total_after_discount.Visible = True

total_after_discount = Nz(subtotal_invoice) - Nz(discount)

ppn_label.Visible = True

ppn.Visible = True

ppn_label.Top = 1.46 * 620

ppn.Top = 1.46 * 620

If Forms!invoice_outbound!yClosing = 0 Then

ppn = total_after_discount * 0.01

Else

ppn = Left(total_after_discount, Len(total_after_discount) - 2)


End If

total_invoice = Nz(total_after_discount) + Nz(ppn)

Else

ppn_label.Visible = False

ppn.Visible = False

total_after_discount = Nz(subtotal_invoice) - Nz(discount)

End If

End Sub

Private Sub Form_Activate()

On Error Resume Next

Form_invoice_outbound_detail.biaya_kirim_total.Requery

Form_invoice_outbound.subtotal_invoice = Form_invoice_outbound_detail.biaya_kirim_total

If Forms!invoice_outbound!yClosing = 0 Then

Forms!invoice_outbound.ppn = Form_invoice_outbound.subtotal_invoice * 0.01

Else

Forms!invoice_outbound.ppn = Left(Form_invoice_outbound.subtotal_invoice,
Len(Form_invoice_outbound.subtotal_invoice) - 2)

End If

outbound.total_invoice = Nz(Form_invoice_outbound.subtotal_invoice) +
Nz(Form_invoice_outbound.ppn)

If Me!yprinted = True Then

If TypeOf Controls Is TextBox Then control.Locked = True

End If

'refresh

End Sub

Private Sub Form_Current()

On Error Resume Next

DoCmd.Maximize

With Form_invoice_outbound_detail

yKunciHargaAll = yKunciHarga

.yBalikAll = .yBalik

End With

Perhitungan_Total

End Sub
Private Sub Form_Error(DataErr As Integer, Response As Integer)

On Error Resume Next

If DataErr = 7787 Then

Response = acDataErrContinue

Me.Recordset.MovePrevious

Me.Recordset.MoveNext

End If

End Sub

Private Sub cmdSimpan_Click()

On Error Resume Next

DoCmd.SetWarnings False

Dim invoice

invoice = Forms!invoice_outbound!no_invoice

Dim Rs As Recordset

Set Rs = CurrentDb.OpenRecordset("select * from invoice_outbound where no_invoice = '" & Forms!


invoice_outbound!no_invoice & "'")

If Rs.RecordCount > 0 Then Rs.MoveLast

''MsgBox Rs.RecordCount

If Rs.RecordCount <= 0 Then

DoCmd.RunSQL "insert into


invoice_outbound(tgl_invoice,no_invoice,combo1,coli,kg,subtotal_invoice,ppn,total_invoice,dibayar,tgl_
dibayar,nama_penerima,keterangan_ttd)" _

& "values ('" & Format(tgl_invoice, "yyyy-mm-dd") & "' , '" & no_invoice & "','" & Combo1 & "','" & coli &
"','" & kg & "','" & subtotal_invoice & "','" & ppn & "','" & total_invoice & "','" & dibayar & "','" &
Format(tgl_dibayar, "yy-mm-dd") & "','" & nama_penerima & "','" & keterangan_ttd & "')"

Else
DoCmd.RunSQL "update invoice_outbound set tgl_invoice='" & Format(tgl_invoice, "yyyy-mm-dd") &
"',no_invoice='" & no_invoice & "',combo1='" & Combo1 & "',coli='" & coli & "',kg='" & kg &
"',total_invoice='" & total_invoice & "',dibayar='" & dibayar & "',tgl_dibayar='" & Format(tgl_dibayar, "yy-
mm-dd") & "',nama_penerima='" & nama_penerima & "',keterangan_ttd='" & keterangan_ttd & "' where
id =" & Forms!invoice_outbound!id

End If

Set Rs = CurrentDb.OpenRecordset("select * from invoice_outbound where no_invoice = '" & Forms!


invoice_outbound!no_invoice & "'")

'Form_invoice_outbound_detail.Requery

'refresh

DoCmd.GoToControl "invoice_outbound_detail"

'Form_invoice_outbound_detail.no_awb.SetFocus

DoCmd.GoToRecord , , acFirst

For I = 1 To Form_invoice_outbound_detail.Recordset.RecordCount

DoCmd.RunSQL "update invoice_outbound_detail set id = '" & Rs!id & "' where id_detail = forms!
invoice_outbound!invoice_outbound_detail!id_detail"

DoCmd.GoToRecord , , acNext

Next I

DoCmd.GoToRecord , , acPrevious

txtCari.Requery

Dim sumber_data As String

Set Rs = CurrentDb().OpenRecordset("select * from invoice_outbound")

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound where no_invoice


= '" & invoice & "'"

Form_invoice_outbound.RecordSource = Form_invoice_outbound_detail.RecordSource
'refresh

'msgBox "Data suda disimpan!", vbInformation, "Info"

End Sub

Private Sub Combo1_AfterUpdate()

On Error Resume Next

Dim Rs As Recordset

Combo1.Requery

Refresh

Set Rs = CurrentDb.OpenRecordset("select * from customer where nama = '" & Combo1 & "'")

If Rs.RecordCount > 0 Then Rs.MoveLast

If Rs.RecordCount = 0 Then

If MsgBox("Nama combo1 itu tidak ada di database, apaka anda mau menambahkannya?", vbYesNo +
vbInformation, "Info") = vbYes Then

DoCmd.OpenForm "customer_single"

Form_customer_single.nama = Combo1

Forms!customer_single!pilihan = "Outbound"

Form_customer_single.alamat.SetFocus

End If

End If

End Sub

Private Sub Form_Load()

On Error Resume Next


'resizeform me

'ReSizeForm Form_invoice_outbound_detail

cmdCari.Left = cmdCariTanggal.Left + cmdCariTanggal.Width + 25

cmdCariFaktur.Left = cmdCari.Left + cmdCari.Width + 25

cmdCariKode.Left = cmdCariFaktur.Left + cmdCariFaktur.Width + 25

cmdUrutkanTglAwb.Left = cmdCariKode.Left + cmdCariKode.Width + 25

cmdPODBelumBalik.Left = cmdUrutkanTglAwb.Left + cmdUrutkanTglAwb.Width + 25

cmdCetakFaktur.Left = cmdPODBelumBalik.Left + cmdPODBelumBalik.Width + 25

cmdCetakPerTanggal.Left = cmdCetakFaktur.Left + cmdCetakFaktur.Width + 25

cmdPecahTanggal.Left = cmdCetakPerTanggal.Left + cmdCetakPerTanggal.Width + 25

cmdPecahKode.Left = cmdPecahTanggal.Left + cmdPecahTanggal.Width + 25

cmdPecahBeban.Left = cmdPecahKode.Left + cmdPecahKode.Width + 25

cmdPecahAWB.Left = cmdPecahBeban.Left + cmdPecahBeban.Width + 25

cmdKeluar.Left = cmdPecahAWB.Left + cmdPecahAWB.Width + 25

DoCmd.SetWarnings False

DoCmd.Maximize

End Sub

Private Sub txtCari_AfterUpdate()

On Error Resume Next

Dim sumber_data As String

Dim Rs As Recordset
Set Rs = CurrentDb().OpenRecordset("select * from invoice_outbound")

Form_invoice_outbound_detail.RecordSource = "SELECT * FROM invoice_outbound where id = " &


txtCari & ""

Form_invoice_outbound.RecordSource = Form_invoice_outbound_detail.RecordSource

'refresh

End Sub

Private Sub no_invoice_AfterUpdate()

On Error Resume Next

'Dim Rs As Recordset

'Set Rs = CurrentDb.OpenRecordset("select * from invoice_outbound where no_invoice = '" & no_invoice


& "'")

'If Rs.RecordCount > 0 Then Rs.MoveLast

'If Rs.RecordCount > 0 Then

no_invoice.Requery

Refresh

'MsgBox no_invoice

DoCmd.SetWarnings False

DoCmd.RunSQL "update invoice_outbound set no_invoice = '" & no_invoice & "' where customer = '" &
Combo1 & "' and bulan = " & combo2 & " and tahun = " & combo3 & ""

'End If

End Sub

Private Sub tgl_invoice_AfterUpdate()

tgl_invoice.Requery

Refresh

'MsgBox tgl_invoice
DoCmd.SetWarnings False

DoCmd.RunSQL "update invoice_outbound set tgl_invoice = '" & tgl_invoice & "' where
customer_bulan_tahun = Combo1 & ' ' & combo2 & ' ' & combo3"

End Sub

Private Sub usr_Click()

On Error Resume Next

If DLookup("lvl", "lgn") <> "admin" And DLookup("lvl", "lgn") <> "eka" Then

MsgBox "Anda tidak berhak merubah user!", vbInformation, "Info"

Else

Me.usr.Locked = False

End If

End Sub

Private Sub ydisc_AfterUpdate()

Perhitungan_Total

End Sub

Private Sub yPPN_AfterUpdate()

Perhitungan_Total

End Sub
Sub penomeran()

On Error Resume Next

Dim Urut As Long

Set Rs = Form_invoice_outbound_detail.RecordsetClone

With Rs

'If Not .EOF Then

.MoveFirst

Form_invoice_outbound_detail.nom = 1

DoCmd.GoToRecord , , acGoTo, 2

Do Until .EOF

Urut = Urut + 1

.Edit

!nom = Urut

.Update

.MoveNext

Loop

'End If

.Close

End With
Form_invoice_outbound_detail.Requery

Refresh

End Sub

Sub Perhitungan_Total()

On Error Resume Next

With Form_invoice_outbound_detail

If IsNull(.pengali) Or IsNull(.pengali) Or .pengali = "berat" Then

If .yKunciBiayaKirim = False Then .biaya_kirim = Nz(.berat * .tarif) + Nz(.biaya_packing)

Else

If .yKunciBiayaKirim = False Then .biaya_kirim = Nz(.qty * .tarif) + Nz(.biaya_packing)

End If

.biaya_kirim.Requery

Refresh

End With
Dim Rs As DAO.Recordset

Dim total As Currency

Set Rs = CurrentDb.OpenRecordset("SELECT * FROM invoice_outbound_detail where customer= '" &


Combo1 & "' And bulan = " & combo2 & " And tahun = " & combo3 & "")

While Not Rs.EOF

total = total + Nz(Rs!biaya_kirim)

Rs.MoveNext

Wend

subtotal_invoice = total

With Me

'Ada discount

If .ydisc = True Then

'Ada PPN

If .yPPN = True Then

'1. Ada Discount dan PPN

.discount_label.Visible = True
.discount.Visible = True

.discount_label.Top = 0.46 * 620

.discount.Top = 0.46 * 620

.discount.SetFocus

.total_after_discount_label.Visible = True

.total_after_discount.Visible = True

.total_after_discount_label.Top = 0.96 * 620

.total_after_discount.Top = 0.96 * 620

.total_after_discount = Nz(.subtotal_invoice) - Nz(.discount)

.ppn_label.Visible = True

.ppn.Visible = True

.ppn_label.Top = 1.46 * 620

.ppn.Top = 1.46 * 620

If Forms!invoice_outbound!yClosing = 0 Then

.ppn = total_after_discount * 0.01

Else

.ppn = Left(.total_after_discount, Len(.total_after_discount) - 2)

End If

.total_invoice_label.Visible = True

.total_invoice.Visible = True

.total_invoice_label.Top = 1.96 * 620

.total_invoice.Top = 1.96 * 620

.total_after_discount = Nz(.subtotal_invoice) - Nz(.discount)


.total_invoice = Nz(.total_after_discount) + Nz(.ppn)

Else

'2. Ada discount saja

.discount_label.Visible = True

.discount.Visible = True

.discount_label.Top = 0.46 * 620

.discount.Top = 0.46 * 620

.discount.SetFocus

.total_after_discount_label.Visible = True

.total_after_discount.Visible = True

.total_after_discount_label.Top = 0.96 * 620

.total_after_discount.Top = 0.96 * 620

.total_after_discount = Nz(.subtotal_invoice) - Nz(.discount)

.ppn_label.Visible = False

.ppn.Visible = False

.ppn = 0

.total_invoice_label.Visible = False

.total_invoice.Visible = False

.total_after_discount = Nz(.subtotal_invoice) - Nz(.discount)

.total_invoice = Nz(.total_after_discount)

End If

Else

'Ada PPN
If .yPPN = True Then

'3. Ada PPN saja

.discount_label.Visible = False

.discount.Visible = False

.discount = 0

.total_after_discount_label.Visible = False

.total_after_discount.Visible = False

.total_after_discount = 0

.ppn_label.Visible = True

.ppn.Visible = True

.ppn_label.Top = 0.46 * 620

.ppn.Top = 0.46 * 620

If Forms!invoice_outbound!yClosing = 0 Then

.ppn = .subtotal_invoice * 0.01

Else

.ppn = Left(.subtotal_invoice, Len(.subtotal_invoice) - 2)

End If

.total_invoice_label.Visible = True

.total_invoice.Visible = True

.total_invoice_label.Top = 0.96 * 620

.total_invoice.Top = 0.96 * 620

.total_after_discount = Nz(.subtotal_invoice) - Nz(.discount)

.total_invoice = Nz(.total_after_discount) + Nz(.ppn)


Else

'4. Nggak ada apa-apa

.discount_label.Visible = False

.discount.Visible = False

.discount = 0

.total_after_discount_label.Visible = False

.total_after_discount.Visible = False

.total_after_discount = 0

.ppn_label.Visible = False

.ppn.Visible = False

.total_invoice_label.Visible = True

.total_invoice.Visible = True

.total_invoice_label.Top = 0.46 * 620

.total_invoice.Top = 0.46 * 620

.total_invoice = .subtotal_invoice

End If

End If

End With

End Sub

You might also like