0% found this document useful (0 votes)
32 views3 pages

Transaksi One To One

This document describes how to create a one-to-one transaction form in Microsoft Access. It includes steps to: 1. Create new tables to store transaction and product data 2. Add form controls bound to the tables for data entry 3. Write VBA code to automatically generate transaction IDs, lookup product details, calculate totals, and save/delete records. The form allows users to lookup customers and products, enter quantities and calculate totals for transactions, and save, delete, or cancel transactions using the buttons and control events coded in VBA.

Uploaded by

SyaTug's
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Transaksi One To One

This document describes how to create a one-to-one transaction form in Microsoft Access. It includes steps to: 1. Create new tables to store transaction and product data 2. Add form controls bound to the tables for data entry 3. Write VBA code to automatically generate transaction IDs, lookup product details, calculate totals, and save/delete records. The form allows users to lookup customers and products, enter quantities and calculate totals for transactions, and save, delete, or cancel transactions using the buttons and control events coded in VBA.

Uploaded by

SyaTug's
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab G Sore vsc/Deni www.indrawan21.

tk
1
Desain Form :



PERTEMUAN 13
Transaksi One To One
1. Membuat Tabel Baru
Pilih Add Ins Pilih Visual Data Manager
Pada Jendela Visdata Pilih File OpenDatabaseMicrosoft AccessFolder Nim PenjualanOpen
Kemudian, klik kanan pada Properties, pilih New Table
Table Name: Transaksi , klik Add Field

Name Type Size
nofak Text 5
tglfak Date/Time 8
kode_brg Text 5
nama_brg Text 30
kode_plg Text 5
nama_plg Text 30
jumbel Single 4
total Currency 8

Klik Add Index, Name=no, Pada Available Fields : nofak
Build The table

2. Menambah Objek dalam Form :
Dari Menu Project Components
Pilih Objek yang akan digunakan dengan cek list kotak depan objeknya OK.
Cara Lain dengan tekan Ctrl + T atau dengan Cara Klik Kanan Pada Toolbox Components



























Primary Key
Data Barang:
1. Name : dtbarang
2. Databasename : C:/Lab C
Sore/1208./Penjualan.mdb
3. Recordsource : Barang
4. Recordset Type : 0-Table.

Data Transaksi:
1. Name : dttransaksi
2. Databasename : C:/Lab C
Sore/1208./Penjualan.mdb
3. Recordsource : Transaksi
4. Recordset Type : 0-Table.

Microsoft Data Bound List
Control 6.0 (DB Combo)
Name : cbokobar
Rowsource : dtbarang
Listfield : kode_brg
BoundColumn : kode_brg

Microsoft Data Bound Grid
Control 5.0 (DB Grid)
Datasource : dttransaksi
Data Pelanggan:
1. Name : dtpelanggan
2. Databasename : C:/Lab C
Sore/1208./Penjualan.mdb
3. Recordsource : Pelanggan
4. Recordset Type : 0-Table.

Lab G Sore vsc/Deni www.indrawan21.tk
2























































Sub aktif()
txtnofak.Enabled = True
txttglfak.Enabled = True
txtkode_plg.Enabled = True
txtnama_plg.Enabled = True
cbokobar.Enabled = True
txtnama_brg.Enabled = True
txtharga.Enabled = True
txtsatuan.Enabled = True
txtjumbel.Enabled = True
txttotal.Enabled = True
txtubay.Enabled = True
txtukem.Enabled = True
End Sub

Sub bersih()
txtnofak = ""
txttglfak = ""
txtkode_plg = ""
txtnama_plg = ""
cbokobar = ""
txtnama_brg = ""
txtharga = ""
txtsatuan = ""
txtjumbel = ""
txttotal = ""
txtubay = ""
txtukem = ""
End Sub

Sub nonaktif()
txtnofak.Enabled = False
txttglfak.Enabled = False
txtkode_plg.Enabled = False
txtnama_plg.Enabled = False
cbokobar.Enabled = False
txtnama_brg.Enabled = False
txtharga.Enabled = False
txtsatuan.Enabled = False
txtjumbel.Enabled = False
txttotal.Enabled = False
txtubay.Enabled = False
txtukem.Enabled = False
End Sub

Sub auto()
Dim urutan As String * 5
Dim hitung As Long
With dttransaksi.Recordset
If .RecordCount = 0 Then
urutan = "F" + "001"
Else
.MoveLast
If Left(!nofak, 1) <> "F" Then
urutan = "F" + "001"
Else
hitung = (Right(!nofak, 3)) + 1
urutan = "F" + Right("000" & hitung, 3)
End If
End If
txtnofak = urutan
End With
End Sub

Private Sub Form_Activate()
Call nonaktif
Call bersih
End Sub

Private Sub cmdadd_Click()
Call aktif
Call bersih
Call auto
txtkode_plg.SetFocus
End Sub

Private Sub cmdsave_Click()
With dttransaksi.Recordset
.AddNew
!nofak = txtnofak
!tglfak = txttglfak
!kode_plg = txtkode_plg
!nama_plg = txtnama_plg
!kode_brg = cbokobar
!nama_brg = txtnama_brg
!jumbel = txtjumbel
!total = txttotal
.Update
End With
Call bersih
Call nonaktif
End Sub

Private Sub cmddelete_Click()
a = MsgBox("Yakin Ingin Menghapus Data Ini ??", vbQuestion +
vbYesNo, "Hapus Data")
If a = vbYes Then
dttransaksi.Recordset.Delete
dttransaksi.Recordset.MoveFirst
Call bersih
Call nonaktif
End If
End Sub

Private Sub cmdcancel_Click()
Form_Activate
End Sub

Private Sub txtkode_plg_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cbokobar.SetFocus
dtpelanggan.Recordset.Index = "kd_plg"
dtpelanggan.Recordset.Seek "=", txtkode_plg
If Not dtpelanggan.Recordset.NoMatch Then
txtnama_plg = dtpelanggan.Recordset!nama_plg
Else
MsgBox "Nama Pelanggan Tidak Terdaftar!!", , "Info"
txtkode_plg.SetFocus
txtkode_plg = ""
End If
End If
End Sub

Private Sub cbokobar_Change()
dtbarang.Recordset.Index = "kode"
dtbarang.Recordset.Seek "=", cbokobar.Text
If Not dtbarang.Recordset.NoMatch Then
txtnama_brg =dtbarang.Recordset!nama_brg
txtharga = dtbarang.Recordset!harga
txtsatuan = dtbarang.Recordset!satuan
txtjumbel.SetFocus
End If
End Sub

Private Sub txtjumbel_KeyPress (KeyAscii As Integer)
If KeyAscii = 13 Then
txttotal = Val(txtjumbel) * Val(txtharga)
txtubay.SetFocus
End If
End Sub

Lab G Sore vsc/Deni www.indrawan21.tk
3



Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtukem = Val(txtubay) - Val(txttotal)
End If
End Sub


Private Sub cmdclose_Click()
p = MsgBox("Yakin Mau Keluar?", vbQuestion + vbYesNo, "Tanya")
If p = vbYes Then
Unload Me
End If
End Sub

You might also like