Sub bersih()
cbkode = ""
tnama = ""
tharga = ""
tstok = ""
tjml = ""
tsubtotal = ""
End Sub
Private Sub cbaru_Click()
'Nomor Otomatis
If djual.Recordset.RecordCount > 0 Then
djual.Recordset.MoveLast
tno.Text = Val(djual.Recordset!notrans) + 1
Else
tno.Text = 1
End If
ttgl.Text = Date
bersih
End Sub
Private Sub Form_Activate()
'isi combo kode barang
dbar.Recordset.MoveFirst
Do While dbar.Recordset.EOF = False
cbkode.AddItem dbar.Recordset!kdbrg
dbar.Recordset.MoveNext
Loop
End Sub
Private Sub cbkode_Click()
dbar.Recordset.Index = "ikode"
dbar.Recordset.Seek "=", cbkode.Text
tnama.Text = dbar.Recordset!nmbrg
tharga.Text = dbar.Recordset!harga
tstok.Text = dbar.Recordset!stok
tjml.SetFocus
End Sub
Private Sub tjml_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Val(tjml.Text) > Val(tstok.Text) Then
MsgBox "Stok barang habis"
tjml = ""
Else
tsubtotal.Text = Val(tjml) * Val(tharga)
ctambah.SetFocus
End If
End If
End Sub
Private Sub ctambah_Click()
dbar.Recordset.Edit
dbar.Recordset!stok = Val(dbar.Recordset!stok) - Val(tjml)
dbar.Recordset.Update
dsem.Recordset.AddNew
With dsem.Recordset
!kdbrg = cbkode
!nmbrg = tnama
!harga = Val(tharga)
!jml = Val(tjml)
!subtotal = Val(tsubtotal)
End With
dsem.Recordset.Update
ttotal.Text = Val(ttotal) + Val(tsubtotal)
bersih
End Sub
Private Sub csimpan_Click()
djual.Recordset.AddNew
djual.Recordset!tgl = ttgl
djual.Recordset!notrans = tno
djual.Recordset!total = Val(ttotal)
djual.Recordset.Update
MsgBox "data tersimpan"
ttgl = "": tno = "": ttotal = ""
sapubersih
End Sub
Sub sapubersih()
'Hapus isi tabel semijual
dsem.Recordset.MoveFirst
Do While dsem.Recordset.EOF = False
dsem.Recordset.Delete
dsem.Recordset.MoveNext
Loop
End Sub
Ilham Maulana | On: 23 Mei 2010 pukul 21.42
Ada tambahan ....
agar latihan ini bisa di copy ke folder kalian
tambahkan listing berikut ini
kedalam form kalianm
Private Sub Form_Load()
dbar.DatabaseName = App.Path & "\Retail.mdb"
dsem.DatabaseName = App.Path & "\Retail.mdb"
djual.DatabaseName = App.Path & "\Retail.mdb"
End Sub