Algoritma & Permrograman II
Kode Program : “ Koneksi” Klik Kanan Adobrg Pilih ADODC Properties Maka akan muncul tampilan sbb:
Instruktur : Nani Purwati
Program Satu Tahun
Algoritma & Permrograman II
Klik Build Maka akan muncul tampilan sbb:
Pilih Microsoft Jet 4.0 OLEDB Provider Klik Next>> Instruktur : Nani Purwati
Program Satu Tahun
Algoritma & Permrograman II Maka akan muncul tampilan sbb:
Cari database dg cr klik Selanjutnya akan tampil sbb:
Instruktur : Nani Purwati
Program Satu Tahun
Algoritma & Permrograman II
Lalu Klik Test Conenection Jika Koneksi berhasil akan muncul tampilan sbb:
Lalu ok Ok Sampai muncul tampilan sbb:
Instruktur : Nani Purwati
Program Satu Tahun
Algoritma & Permrograman II
Program Satu Tahun
Silakan Ctrl+C UNTUK Copy pada Lalu ketikkan Kede di bawah ini: Private Sub Form_Load() adobrg.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbpenjualan.mdb;Persist Security Info=False" adobrg.RecordSource = "select * from barang order by kdbrg" adobrg.CommandType = adCmdText adobrg.Refresh Set dtbrg.DataSource = adobrg End Sub
Private Sub bersih() txtkdbrg.Text = "" txtnmbrg.Text = "" txthrgjual.Text = "" txthrgbeli.Text = "" txtstok.Text = "" End Sub
Private Sub aktif() txtkdbrg.Enabled = True txtnmbrg.Enabled = True txthrgjual.Enabled = True txthrgbeli.Enabled = True txtstok.Enabled = True End Sub Instruktur : Nani Purwati
Algoritma & Permrograman II
Program Satu Tahun
Private Sub nonaktif() txtkdbrg.Enabled = False txtnmbrg.Enabled = False txthrgjual.Enabled = False txthrgbeli.Enabled = False txtstok.Enabled = False End Sub Private Sub tampil() With adobrg.Recordset txtkdbrg.Text = !kdbrg txtnmbrg.Text = !nmbrg txthrgbeli.Text = !hrgbeli txthrgjual.Text = !hrgsat txtstok.Text = !stok End With End Sub Private Sub cmdadd_Click() Call aktif Call bersih txtkdbrg.SetFocus cmdsave.Enabled = True cmdcancel.Enabled = True cmddelete.Enabled = False End Sub Private Sub cmdcancel_Click() Call bersih cmdsave.Enabled = False cmddelete.Enabled = False End Sub Private Sub cmdclose_Click() x = MsgBox("Pekerjaan Anda Sudah Selesai..?", vbYesNo + vbQuestion, "..:Pesan:..") If x = vbYes Then Unload Me End If End Sub
Instruktur : Nani Purwati
Algoritma & Permrograman II
Program Satu Tahun
Private Sub cmddelete_Click() x = MsgBox("Yakin Data Akan di hapus?", vbYesNo + vbQuestion, "..:Informasi:..") If x = vbYes Then adobrg.Recordset.Delete MsgBox "Data Telah Terhapus!" Call aktif Call bersih End If Call nonaktif End Sub Private Sub cmdedit_Click() If cmdedit.Caption = "E&DIT" Then Call aktif txtkdbrg.Enabled = False cmdedit.Caption = "UP&DATE" Else With adobrg.Recordset !nmbrg = txtnmbrg !hrgbeli = txthrgbeli !stok = txtstok !hrgsat = txthrgjual adobrg.Recordset.Update MsgBox "Perubahan Data Tersimpan!" Call nonaktif End With cmdedit.Caption = "E&DIT" End If End Sub Private Sub cmdfirst_Click() On Error Resume Next adobrg.Recordset.MoveFirst Call tampil Call nonaktif End Sub Private Sub cmdlast_Click() On Error Resume Next adobrg.Recordset.MoveLast Call tampil
Instruktur : Nani Purwati
Algoritma & Permrograman II
Program Satu Tahun
Call nonaktif End Sub
Private Sub cmdnext_Click() On Error Resume Next adobrg.Recordset.MoveNext If adobrg.Recordset.EOF Then MsgBox "Anda Sudah di akhir record!", vbOKOnly + vbInformation, "..:Informasi:.." adobrg.Recordset.MoveLast End If Call tampil Call nonaktif End Sub Private Sub cmdpre_Click() On Error Resume Next adobrg.Recordset.MovePrevious If adobrg.Recordset.BOF Then MsgBox "Anda Sudah Diawal Record!", vbOKOnly + vbInformation, "..:Informasi:.." adobrg.Recordset.MoveFirst End If Call tampil Call nonaktif End Sub Private Sub cmdsave_Click() With adobrg.Recordset .AddNew !kdbrg = txtkdbrg !nmbrg = txtnmbrg !hrgbeli = txthrgbeli !hrgsat = txthrgjual !stok = txtstok .Update MsgBox "Data Telah tersimpan!", vbOKOnly + vbInformation, "..:Informasi:.." cmdsave.Enabled = False End With Call nonaktif cmdcancel.Enabled = False End Sub
Instruktur : Nani Purwati
Algoritma & Permrograman II
Private Sub Form_Activate() Call tampil txtkdbrg.MaxLength = 8 txtnmbrg.MaxLength = 20 txthrgbeli.MaxLength = 8 txthrgjual.MaxLength = 8 txtstok.MaxLength = 3 Call nonaktif cmdsave.Enabled = False cmdcancel.Enabled = False adobrg.Visible = False dtbrg.Enabled = False End Sub
Private Sub SSTab1_Click(PreviousTab As Integer) txtcrkd.SetFocus End Sub
Private Sub txthrgbeli_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txthrgjual.SetFocus End If End Sub
Private Sub txthrgjual_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtstok.SetFocus End If End Sub
Private Sub txtkdbrg_KeyPress(KeyAscii As Integer)
Instruktur : Nani Purwati
Program Satu Tahun
Algoritma & Permrograman II If KeyAscii = 13 Then txtnmbrg.SetFocus End If End Sub
Private Sub txtnmbrg_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txthrgbeli.SetFocus End If End Sub
Instruktur : Nani Purwati
Program Satu Tahun