You are on page 1of 8

Private Sub cmdCetak_Click()

On Error Resume Next

MsgBox "Jangan lupa cek total dulu sebelum cetak invoice!", vbInformation, "Peringatan"

Me!yprinted = True

Me!usr = "eka"

DoCmd.OpenForm "pilihanCetak"

If Me!yprinted = 0 Then

Dim ctrl As control

For Each ctrl In Me.Controls

If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Or TypeOf ctrl Is OptionButton Or TypeOf ctrl Is
SubForm Then

ctrl.Locked = False

End If

Next

Else

For Each ctrl In Me.Controls

If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Or TypeOf ctrl Is OptionButton Or TypeOf ctrl Is
SubForm Then

ctrl.Locked = True

End If

Next
End If

Forms!pilihanCetak.Caption = "invoice_borongan"

End Sub

Private Sub cmdDataBaru_Click()

DoCmd.GoToRecord , , acNewRec

End Sub

Private Sub cmdHapus_Click()

On Error Resume Next

DoCmd.SetWarnings False

Dim norut As String

norut = CurrentRecord

If MsgBox("Apa anda yakin mau menghapus data ini?", vbInformation + vbYesNo, "Info") = vbYes Then

DoCmd.RunSQL "delete * from invoice_borongan_detail where id = forms!invoice_borongan!id"

DoCmd.RunSQL "delete * from invoice_borongan where id = forms!invoice_borongan!id"

RecordSource = "invoice_borongan"

DoCmd.GoToRecord , , acGoTo, norut - 1

End If

End Sub
Private Sub cmdKeluar_Click()

On Error Resume Next

DoCmd.Close

End Sub

Private Sub cmdPecah_Click()

On Error Resume Next

DoCmd.SetWarnings False

DoCmd.RunSQL "delete * from invoice_borongan_pecahan_detail where no_invoice = '" & no_invoice &
"'"

DoCmd.RunSQL "insert into invoice_borongan_pecahan_detail (id, nom, tipe, biaya_kirim, bulan, tahun,
no_invoice) SELECT id, nom, tipe, biaya_kirim, bulan, tahun, no_invoice " _

& "FROM invoice_borongan_detail " _

& "GROUP BY id, nom, tipe, biaya_kirim, bulan, tahun, no_invoice;"

Dim Rs As DAO.Recordset

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


no_invoice & "'")

DoCmd.OpenForm "invoice_borongan_pecahan", , , "(no_invoice = '" & no_invoice & "')"

Form_invoice_borongan_pecahan.SetFocus

If Rs.RecordCount = 0 Then

'MsgBox rs!no_invoice

DoCmd.GoToRecord , , acNewRec

Form_invoice_borongan_pecahan.no_invoice = Me!no_invoice

Form_invoice_borongan_pecahan!id = Me!id

Form_invoice_borongan_pecahan!customer = Me!customer
Form_invoice_borongan_pecahan!tgl_invoice = Me!tgl_invoice

Form_invoice_borongan_pecahan!subtotal_invoice = Me!subtotal_invoice

Form_invoice_borongan_pecahan!ppn = Me!ppn

Form_invoice_borongan_pecahan!total_invoice = Me!total_invoice

Else

DoCmd.FindRecord Rs!no_invoice

Form_invoice_borongan_pecahan!id = Me!id

Form_invoice_borongan_pecahan!customer = Me!customer

Form_invoice_borongan_pecahan!tgl_invoice = Me!tgl_invoice

Form_invoice_borongan_pecahan!subtotal_invoice = Me!subtotal_invoice

Form_invoice_borongan_pecahan!ppn = Me!ppn

Form_invoice_borongan_pecahan!total_invoice = Me!total_invoice

End If

End Sub

Private Sub customer_AfterUpdate()

Form_invoice_borongan.no_invoice.Requery

Refresh

If Forms!invoice_borongan!customer = "PT. Parit Padang Global" Then

If Date < #1/31/2022# Then

Form_invoice_borongan_detail.biaya_kirim = 18750000

Form_invoice_borongan.subtotal_invoice = 18750000
If Forms!invoice_borongan!tgl_invoice >= #4/1/2022# Then

Form_invoice_borongan.ppn = 18750000 * 0.011

Else

Form_invoice_borongan.ppn = 18750000 * 0.01

End If

Else

Form_invoice_borongan_detail.biaya_kirim = 20450000

Form_invoice_borongan.subtotal_invoice = 20450000

If Forms!invoice_borongan!tgl_invoice >= #4/1/2022# Then

Form_invoice_borongan.ppn = 20450000 * 0.011

Else

Form_invoice_borongan.ppn = 20450000 * 0.01

End If

If Forms!invoice_borongan!tgl_invoice >= #9/30/2022# Then

Form_invoice_borongan_detail.biaya_kirim = 70000000

Form_invoice_borongan.subtotal_invoice = 70000000

Form_invoice_borongan.ppn = 70000000 * 0.011

Form_invoice_borongan.total_invoice = 70000000 * 1.011

End If

If Left(Forms!invoice_borongan!no_invoice, 4) = "6014" Then


Form_invoice_borongan_detail.biaya_kirim = 40021150

Form_invoice_borongan.subtotal_invoice = 40021150

Form_invoice_borongan.ppn = 40021150 * 0.011

Form_invoice_borongan.total_invoice = 40021150 * 1.011

End If

End If

Else

Form_invoice_borongan_detail.biaya_kirim = 39500000

Form_invoice_borongan.subtotal_invoice = 39500000

If Forms!invoice_borongan!tgl_invoice >= #4/1/2022# Then

Form_invoice_borongan.ppn = 39500000 * 0.011

If Forms!invoice_borongan!tgl_invoice >= #9/30/2022# Then

Form_invoice_borongan_detail.biaya_kirim = 42660000

Form_invoice_borongan.subtotal_invoice = 42660000

Form_invoice_borongan.ppn = 42660000 * 0.011

Form_invoice_borongan.total_invoice = 42660000 * 1.011

End If

If Forms!invoice_borongan!tgl_invoice >= #1/1/2023# Then

Form_invoice_borongan_detail.biaya_kirim = 50922000
Form_invoice_borongan.subtotal_invoice = 50922000

Form_invoice_borongan.ppn = 50922000 * 0.011

Form_invoice_borongan.total_invoice = 50922000 * 1.011

End If

Else

Form_invoice_borongan.ppn = 39500000 * 0.01

End If

End If

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

End Sub

Private Sub customer_DblClick(Cancel As Integer)

DoCmd.OpenForm "customer"

End Sub

Private Sub Form_Current()

DoCmd.Maximize
End Sub

Private Sub Form_Load()

On Error Resume Next

'If Me.Recordset.RecordCount > 0 Then DoCmd.GoToRecord , , acNewRec

DoCmd.Maximize

'resizeform me

DoCmd.GoToRecord , , acLast

customer_AfterUpdate

End Sub

Private Sub usr_Click()

On Error Resume Next

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

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

Else

Me.usr.Locked = False

End If

End Sub

You might also like