Membuat Database
File New Blank database simpan dengan nama: penjualan.mdb (format access
2002-2003)
Membuat tabel
1. Barang
Field name Data Type Field Size Format
Kobar Text 5 Pk
Nabar Text 20
Hbeli Currency Currency
Hjual Currency Currency
Stok Number Long integer
Isi data barang sebanyak 5 record
2. Pengguna
Field name Data Type Field Size Format
Userid Text 5 Pk
Nmuser Text 20
Password Text 10
Akses Text 15
Isi data pengguna sebanyak 5 record dan akses = admin.
3. Faktur
Field name Data Type Field Size Format
Nofak Text 10 Pk
Tglfak Date/time
Userid Text 20
Total Currency Currency
4. Detailfak
Field name Data Type Field Size Format
Nofak Text 10
Qty Number Long integer
Subtotal Currency Currency
Kobar Text 5
5. Tmpjual
Field name Data Type Field Size Format
Nofak Text 10
Kobar Text 5
Nabar Text 20
Hjual Currency Currency
Qty Number Long integer
Subtotal Currency Currency
1
VB II PERTEMUAN PRA UTS
Membuat Relationship
Mengaktifkan VB
StartAll Program Microsoft Visual Studio 6.0 Microsoft Visual basic 6.0
Membuat Project
File New project simpan dengan nama: penjualan.pjx
2
VB II PERTEMUAN PRA UTS
Menambahkan Komponen
Komponen yang ditambahkan:
1. Tab
2. Adodc
3. MSHFleshGrid
4. Cristal Report
Cara: Tekan CTRL + T atau klik kanan pada components sehingga muncul kotak dialog
components
3
VB II PERTEMUAN PRA UTS
Pengkoneksian
1. Koneksi Adodc
c. Pilih use connection string Build Microsoft Jet 4.0 OLE DB ProviderNext
4
VB II PERTEMUAN PRA UTS
e. Pada select or enter a database name klik ... (ke folder database penjualan.mdb
yang telah dibuat sebelumnya open)
f. Klik Test Connection Ok Ok
g. Setelah itu pada jendela Properties pilih RecordSource
h. Tampil jendela Property pages
2. Koneksi MSHFlexGrid
5
VB II PERTEMUAN PRA UTS
Sub tabel()
Grid1.Cols = 6
Grid1.Rows = 10
Grid1.ColWidth(0) = 200
Grid1.ColWidth(1) = 500
Grid1.ColWidth(2) = 2000
Grid1.ColWidth(3) = 1500
Grid1.ColWidth(4) = 1500
Grid1.ColWidth(5) = 500
Grid1.ColAlignment(1) = 3
End Sub
Sub awal()
Adojual.RecordSource = "select * from barang"
Adojual.Refresh
tkobar.Enabled = False
tnabar.Enabled = False
thbeli.Enabled = False
thjual.Enabled = False
tstok.Enabled = False
End Sub
Sub bersih()
tkobar = ""
tnabar = ""
thbeli = ""
thjual = ""
tstok = ""
End Sub
Sub aktif()
tkobar.Enabled = True
tnabar.Enabled = True
thbeli.Enabled = True
thjual.Enabled = True
tstok.Enabled = True
End Sub
Sub tampil()
tkobar.Text = Adojual.Recordset.Fields("kobar")
tnabar.Text = Adojual.Recordset.Fields("nabar")
6
VB II PERTEMUAN PRA UTS
thbeli.Text = Adojual.Recordset.Fields("hbeli")
thjual.Text = Adojual.Recordset.Fields("hjual")
tstok.Text = Adojual.Recordset.Fields("stok")
End Sub
7
VB II PERTEMUAN PRA UTS
End Sub
8
VB II PERTEMUAN PRA UTS
If Adojual.Recordset.BOF Then
MsgBox "Data sudah di awal record", 48, "Info"
Adojual.Recordset.MoveFirst
End If
tampil
End Sub
9
VB II PERTEMUAN PRA UTS
• 1 buah Data Combo (Microsoft Data List Control 6.0 (OLEDB)), pada jendela
properties Rowsource: dtbarang , ListField: kobar
10
VB II PERTEMUAN PRA UTS
11
VB II PERTEMUAN PRA UTS
12
VB II PERTEMUAN PRA UTS
13
VB II PERTEMUAN PRA UTS
14
VB II PERTEMUAN PRA UTS
15
VB II PERTEMUAN PRA UTS
16
VB II PERTEMUAN PRA UTS
Tampil Jendela Standart report Expert, klik Database muncul jendela Data explorer,
klik Find Database File ADD
17
VB II PERTEMUAN PRA UTS
18
VB II PERTEMUAN PRA UTS
Hasil:
19
VB II PERTEMUAN PRA UTS
Start all Program Microsoft Visual Studia 6.0 Microsoft Visual basic 6.0.
File Open Project Buka Project penjualan.vbp
Tekan CTRL+T sehingga muncul kotak dialog Component seperti dibawah ini:
20
VB II PERTEMUAN PRA UTS
C:\LABO
MALAM\NIM\reportbarang
Lalu Klik OK
21
VB II PERTEMUAN PRA UTS
22
VB II PERTEMUAN PRA UTS
7. Hasil sbb:
8. Listing Program:
23