You are on page 1of 8

Pemrograman Visual II (RUR/Ali) Buat database menggunakan Microsoft Access 2003

Database Name : penjualan

Table Name : pengguna Field Type Field Size Format Name Data Userid Text 5 Nmuser Text 20 Password Text 10 Akses Text 15

Keterangan Primary Key

Table Name : faktur Field Type Data Field Size Format Keterangan Name Nofak Text 10 Primary Key Tglfak Date/time Longdate Userid Text 5 Foreign key Table Name : detail_faktur Field Type Field Size Format Name Data Nofak Text 10 Jumbel Number Integer Subtotal Currency Currency Kode Text 5 Table Name : tmptran Field Type Field Size Name Data Kode Text 5 Nama Text 20 Hrgjual Currency Jumbel Number Subtotal Currency

Keterangan Foreign key

Foreign key

Format

Keterangan Foreign Key

Currency Integer Currency

mhanurika.blogspot.com

Pemrograman Visual II (RUR/Ali) Design Form sebagai berikut :

Komponen u/ Data Combo : Microsoft DataList Control 6.0 (OLEDB) Pengkoneksian Data Combo : Row Source : Ado_pengguna List Field : userid Recordsource : select * from barang Recordsource : select * from detail_faktur Recordsource : select * from faktur Recordsource : select * from pengguna Recordsource : select * from tmptran Pengkoneksian MSHFlexgrid1 : Datasource : Ado_tmptran

mhanurika.blogspot.com

Pemrograman Visual II (RUR/Ali) Listing program :


Sub nonaktif() txtnofak.Enabled = False txttglfak.Enabled = False txtnmuser.Enabled = False txtkode.Enabled = False txtnama.Enabled = False txthrgjual.Enabled = False txtstok.Enabled = False txtjumbel.Enabled = False txtsubtotal.Enabled = False txttotal.Enabled = False txtubay.Enabled = False txtukem.Enabled = False txtjam.Enabled = False End Sub Sub aktif() txtkode.Enabled = True txtjumbel.Enabled = True txtubay.Enabled = True End Sub Sub bersih() txtnmuser.Text = "" txtkode.Text = "" txtnama.Text = "" txthrgjual.Text = "" txtstok.Text = "" txtjumbel.Text = "" txtsubtotal.Text = "" txttotal.Text = "" txtubay.Text = "" txtukem.Text = "" End Sub Sub tabel() grid.Cols = 6 grid.Rows = 10 grid.ColWidth(0) = 200 grid.ColWidth(1) = 1000 grid.ColWidth(2) = 1000 grid.ColWidth(3) = 1000 grid.ColWidth(4) = 1000 grid.ColWidth(5) = 1000 End Sub

mhanurika.blogspot.com

Pemrograman Visual II (RUR/Ali)


Sub no_auto() Ado_faktur.RecordSource = "select * from faktur where nofak='" & txtnofak.Text & "'" Ado_faktur.Refresh With Ado_faktur.Recordset If .BOF And .EOF Then txtnofak.Text = "F" + Format(Date, "yyyy") & Format(Date, "mm") & "001" Else .MoveLast txtnofak.Text = "F" + Format(Date, "yyyy") & Format(Date, "mm") & Right(Str(Val(Right(!nofak, 4)) + 10001), 3) End If End With End Sub Sub HapusGrid() If Ado_tmptran.Recordset.RecordCount <= 0 Then Exit Sub End If Ado_tmptran.Recordset.MoveFirst Do While Not Ado_tmptran.Recordset.EOF Ado_tmptran.Recordset.Delete Ado_tmptran.Recordset.MoveNext Loop Ado_tmptran.Refresh End Sub Private Sub cmdbatal_Click() If txtjumbel.Text <> "" Then Ado_barang.Recordset.Fields("stok") = Ado_barang.Recordset.Fields("stok") + Val(txtjumbel.Text) Ado_barang.Recordset.Update End If Call nonaktif Call bersih Call HapusGrid Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh End Sub Private Sub cmdkeluar_Click() Unload Me End Sub Private Sub cmdsimpan_Click() Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh

mhanurika.blogspot.com

Pemrograman Visual II (RUR/Ali)


Ado_detail_fak.RecordSource = "select * from detail_fak" Ado_detail_fak.Refresh Ado_tmptran.Recordset.MoveFirst n=1 While Not Ado_tmptran.Recordset.EOF Ado_detail_fak.Recordset.AddNew Ado_detail_fak.Recordset.Fields("nofak") = txtnofak.Text Ado_detail_fak.Recordset.Fields("kode") = Ado_tmptran.Recordset.Fields("kode") Ado_detail_fak.Recordset.Fields("jumbel") = Ado_tmptran.Recordset.Fields("jumbel") Ado_detail_fak.Recordset.Fields("subtotal") = Ado_tmptran.Recordset.Fields("subtotal") Ado_detail_fak.Recordset.Update Ado_tmptran.Recordset.MoveNext n=n+1 Wend With Ado_faktur.Recordset .AddNew .Fields("nofak") = txtnofak.Text .Fields("tglfak") = txttglfak.Text .Fields("userid") = DataCombo1.Text .Update End With Call bersih Call nonaktif Call HapusGrid Form_Activate End Sub Private Sub cmdtambah_Click() Call no_auto Call aktif Call bersih End Sub Private Sub DataCombo1_Click(Area As Integer) Ado_pengguna.RecordSource = "select * from pengguna" Ado_pengguna.Recordset.MoveFirst Do While Not Ado_pengguna.Recordset.EOF If DataCombo1.Text = Ado_pengguna.Recordset!userid Then txtnmuser.Text = Ado_pengguna.Recordset!nmuser Exit Sub End If Ado_pengguna.Recordset.MoveNext Loop End Sub

mhanurika.blogspot.com

Pemrograman Visual II (RUR/Ali)


Private Sub Form_Activate() Call nonaktif Call bersih Call tabel Call HapusGrid End Sub Private Sub Timer1_Timer() txttglfak.Text = Date txtjam.Text = Time End Sub Private Sub txtjumbel_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh Ado_barang.RecordSource = "select * from barang where kode='" & txtkode.Text & "'" Ado_barang.Refresh txtsubtotal.Text = Val(txtjumbel.Text) * Val(txthrgjual.Text) mha = MsgBox("Mau tambah barang lagi?", 32 + 4, "Lagi") If mha = vbYes Then With Ado_tmptran.Recordset Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh Ado_barang.RecordSource = "select * from barang where kode='" & txtkode.Text & "'" Ado_barang.Refresh .AddNew .Fields("kode") = txtkode.Text .Fields("nama") = txtnama.Text .Fields("hrgjual") = txthrgjual.Text .Fields("jumbel") = Val(txtjumbel.Text) .Fields("subtotal") = txtsubtotal.Text .Update End With Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh Ado_barang.Recordset.Fields("stok") = Val(txtstok.Text) - Val(txtjumbel.Text) Ado_barang.Recordset.Update 'utk update stok barang txttotal.Text = Val(txttotal.Text) + Val(txtsubtotal.Text) txtkode.Text = "" txtnama.Text = "" txthrgjual.Text = "" txtstok.Text = "" txtjumbel.Text = "" txtsubtotal.Text = ""

mhanurika.blogspot.com

Pemrograman Visual II (RUR/Ali)


txtkode.SetFocus Else 'tidak ingin menambah With Ado_tmptran.Recordset Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh Ado_barang.RecordSource = "select * from barang where kode='" & txtkode.Text & "'" Ado_barang.Refresh .AddNew .Fields("kode") = txtkode.Text .Fields("nama") = txtnama.Text .Fields("hrgjual") = txthrgjual.Text .Fields("jumbel") = Val(txtjumbel.Text) .Fields("subtotal") = txtsubtotal.Text .Update End With Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh Ado_barang.Recordset.Fields("stok") = Val(txtstok.Text) - Val(txtjumbel.Text) Ado_barang.Recordset.Update txttotal.Text = Val(txttotal.Text) + Val(txtsubtotal.Text) txtubay.SetFocus End If Ado_tmptran.RecordSource = "select * from tmptran" Ado_tmptran.Refresh End If End Sub Private Sub txtkode_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) Ado_barang.RecordSource = "select * from barang where kode='" & txtkode.Text & "'" Ado_barang.Refresh If KeyAscii = 13 Then With Ado_barang.Recordset If .BOF And .EOF Then MsgBox "Kode " + txtkode.Text + " Belum ada", 16, "Tanya" txtkode.Text = "" txtkode.SetFocus Else txtnama.Text = .Fields("nama") txthrgjual.Text = .Fields("hrgjual") txtstok.Text = .Fields("stok") End If End With txtjumbel.SetFocus End If

mhanurika.blogspot.com

Pemrograman Visual II (RUR/Ali)


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

mhanurika.blogspot.com

You might also like