• Buat Database dengan nama : db_travel
• Buat Tabel dengan nama: tb_transaksi
Name | Type | Size | Keterangan |
Notrans | Text | 10 | Primary key |
Nama | Text | 20 | |
Alamat | Text | 30 | |
pesawat | Text | 20 | |
Jurusan | Text | 20 | |
Harga | Currency | 8 | |
Biaya | Currency | 8 | |
Jumbel | Currency | 8 | |
Total | Currency | 8 |
1. Buat procedure aktif,nonaktif,kosong dan nomorbaru
2. Pada saat form dijalankan tanggal muncul otomatis dan semua object dalam keadaan tidak aktif
3. Pada saat klik button tambah semua object aktif, nomor transaksi muncul otomatis dan kursor berada pada nama
4. Isi combo dengan : Garuda Air Lines, Air Asia dan Batavia Air
5. Jika pilih option Antar maka biaya muncul. Biaya = 5% * harga tiket
Jika dipilih option Ambil maka biaya = 0
6. Pilih jurusan maka harga tiket akan muncul :
Nama Pesawat | Jurusan | ||
Bandung | semarang | surabaya | |
Garuda Air Lines | 400000 | 450000 | 500000 |
Air Asia | 350000 | 400000 | 550000 |
Batavia Air | 300000 | 350000 | 600000 |
7. Input jumlah beli ketika enter muncul total bayar. Total bayar = jumbel * harga tiket
8. Klik button proses maka total keseluruhan muncul. Total keseluruhan = biaya + total bayar
9. Koneksi data dengan menggunakan listing
10. Klik button cancel maka semua object bersih dan tidak aktif
11. Klik button simpan semua object tersimpan kedalam database
12. Klik button keluar maka muncul pesan :
Desain Form :
Listing Program :
Sub nobaru()
Dim no_pinjam As String
Dim fakint As Integer
Dim db As Database
Dim rstrans As Recordset
no_pinjam = Format(Date, "yymm")
Set db = OpenDatabase(App.Path & "\db_travel.mdb")
Set rstrans = db.OpenRecordset("select notrans from tb_transaksi order by notrans", dbOpenDynaset)
With rstrans
If .RecordCount = 0 Then
no_pinjam = no_pinjam & "0001"
Else
.MoveLast
If Format(Date, "yymm") <> Val(Left(!notrans, 4)) Then
no_pinjam = Format(Date, "yymm") & "0001"
Else
fakint = Val(Right(!notrans, 4)) + 1
no_pinjam = Format(Date, "yymm") & Right("0000" & fakint, 4)
End If
End If
End With
Me.no.Text = no_pinjam
End Sub
Private Sub add_Click()
aktif
bersih
nobaru
cancel.Enabled = True
save.Enabled = True
pro.Enabled = True
nm.SetFocus
End Sub
Private Sub cancel_Click()
bersih
nonaktif
End Sub
Private Sub exit_Click()
Dim p As String
p = MsgBox("Yakin Mau Keluar??", 32 + 4, "Informasi")
If p = vbYes Then
End
End If
End Sub
Private Sub Form_Activate()
nonaktif
bersih
cancel.Enabled = False
save.Enabled = False
pro.Enabled = False
cnm.AddItem ("Garuda Air Lines")
cnm.AddItem ("Air Asia")
cnm.AddItem ("Batavia Air")
lj.AddItem ("Bandung")
lj.AddItem ("Semarang")
lj.AddItem ("Surabaya")
End Sub
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\db_travel.mdb"
Data1.RecordSource = "select*from tb_transaksi"
End Sub
Private Sub jb_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
tb.Text = Val(jb.Text) + Val(h.Text)
End If
End Sub
Private Sub lj_Click()
If cnm.Text = "Garuda Air Lines" Then
If lj.Text = "Bandung" Then
h.Text = 400000
ElseIf lj.Text = "Semarang" Then
h.Text = 450000
Else
h.Text = 500000
End If
ElseIf cnm.Text = "Air Asia" Then
If lj.Text = "Bandung" Then
h.Text = 300000
ElseIf lj.Text = "Semarang" Then
h.Text = 350000
Else
h.Text = 400000
End If
ElseIf cnm.Text = "Batavia Air" Then
If lj.Text = "Bandung" Then
h.Text = 350000
ElseIf lj.Text = "Semarang" Then
h.Text = 400000
Else
h.Text = 4500000
End If
End If
End Sub
Private Sub oam_Click()
If oam.Value = True Then
b.Text = 0
End If
End Sub
Private Sub oan_Click()
If oan.Value = True Then
b.Text = 0.05 * Val(h.Text)
Else
b.Text = 0
End If
End Sub
Private Sub pro_Click()
tk.Text = Val(b.Text) + Val(tb.Text)
End Sub
Private Sub save_Click()
Data1.Recordset.AddNew
Data1.Recordset!notrans = no.Text
Data1.Recordset!tgltrans = tgl.Text
Data1.Recordset!nama = nm.Text
Data1.Recordset!alamat = almt.Text
Data1.Recordset!pesawat = cnm.Text
Data1.Recordset!jurusan = lj.Text
Data1.Recordset!harga = h.Text
Data1.Recordset!biaya = b.Text
Data1.Recordset!jumbel = jb.Text
Data1.Recordset!total = tb.Text
Data1.Recordset.Update
Data1.Refresh
End Sub
Private Sub Timer1_Timer()
tgl.Text = Date
End Sub
Sub aktif()
nm.Enabled = True
almt.Enabled = True
cnm.Enabled = True
lj.Enabled = True
oan.Enabled = True
oam.Enabled = True
b.Enabled = True
h.Enabled = True
jb.Enabled = True
tb.Enabled = True
ub.Enabled = True
End Sub
Sub nonaktif()
no.Enabled = False
tgl.Enabled = False
nm.Enabled = False
almt.Enabled = False
oan.Enabled = False
oam.Enabled = False
cnm.Enabled = False
lj.Enabled = False
b.Enabled = False
h.Enabled = False
jb.Enabled = False
tb.Enabled = False
tk.Enabled = False
ub.Enabled = False
uk.Enabled = False
End Sub
Sub bersih()
no.Text = ""
nm.Text = ""
almt.Text = ""
cnm.Text = ""
oan.Value = False
oam.Value = False
b.Text = ""
h.Text = ""
jb.Text = ""
tb.Text = ""
tk.Text = ""
ub.Text = ""
uk.Text = ""
End Sub
Private Sub ub_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
uk.Text = Val(ub.Text) - tk.Text
End If
End Sub
Baca Selengkapnya......