Modul 1
Koneksi Ke Database dengan ADODC
Langakah 1 : Buat database dengan nama PENJUALAN dengan Ms. Acces,
[Link]-Blank Database
Langkah 2 : Buat Tabel PEMBELIAN dengan field sebagai berikut:
Field Type Width Ket
Kode Barang Text 9 Primary Key
Nama Barang Text 50
Jenis Barang Text 25
Satuan Text 5
Harga Beli Number Long Integer
Create Table In Design View
Langkah 3 : Buat Form Input di Ms. Visual Basic
Properti Setting Ket
Label 1 Input Pembelian
Label 2 Kode Barang
Label 3 Nama Barang
Label 4 Jenis Barang
Label 5 Satuan
Label 6 Harga
Text 1 Txtkd_brg
Text 2 Txtnm_brg
Combo1 Cmb_brg
Combo2 Cmb_stn
Text3 Txthg_brg
Adodc1 Adodc1
Command1 &Simpan
Command2 &Koreksi
Command3 &Hapus
Command4 &Update
DataGrid1 Datagrid1 Data Source: Adodc1
Adodc1 dan DataGrid1 ditambahkan dari Project-Component- Microsoft ADO
Data Control 6.0 (OLEDB) Microsoft DataGrid Control 6.0 (OLEDB)
Source Code:
Private Sub cmb_brg_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmb_stn.SetFocus
End If
End Sub
Private Sub cmb_stn_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txthg_brg.SetFocus
End If
End Sub
Private Sub cmd_smpn_Click()
With [Link]
.AddNew
!Kode_Barang = txtkd_brg.Text
!Nama_Barang = txtnm_brg.Text
!Jenis_Barang = cmb_brg.Text
!Satuan = cmb_stn.Text
!Harga = txthg_brg.Text
.Update
End With
kosong
End Sub
Private Sub kosong()
txtkd_brg.Text = ""
txtnm_brg.Text = ""
cmb_brg.Text = ""
cmb_stn.Text = ""
txthg_brg.Text = ""
End Sub
Private Sub txthg_brg_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmd_smpn.SetFocus
End If
End Sub
Private Sub txtkd_brg_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtnm_brg.SetFocus
End If
End Sub
Private Sub txtnm_brg_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmb_brg.SetFocus
End If
End Sub