A. Pembutan input data petugas 1) Membuat table petugas Buat table dengan nama Tpetugas buat isi table seperti gambar di bawah ini Field name Data type Field size Index kd_ptgs Text 4 Primary key nama Text 25 - tempat Text 15 - tgl_lahir Date/Time - - jklm Text 2 - alamat Text 40 - telepon Text 12 - pass Text 15-2) Membuat form input data petugas Gambar 1 Table Petugas Dalam pembuatan form ini kita membutuhkan component tambahan da untuk menambah komonen tesebut caranya sangat mudah. Tekan Ctrl + T akan ada tampilan seperti gambar berikut : Gambar 2 Penambahan Komonen Pada Form Tambahkan komponen-komponen berikut ini: Microsoft ADO Data Control 6.0 (OLEDB) Microsoft Masked Edit Control 6.0 Microsoft Windows Commend Control 6.0 (SP4) Atur properties Komponen-komponen yang digunakan dalam pembuatan form petugas sebagai berikut
1 form Frm_petugas Input Data Petugas Auto Zize Kode Petuags Nama Tempat/Tgl/Lahir 7 Label Tidak dirubah Jenis Kelamin True Alamat Telepon Pasword Cmdsimpan &SIMPAN Cmdbatal &BATAL 5 commondbutton Cmdhapus &HAPUS Cmdkeluar &KELUAR Cmdcari &CARI Komponen Name Text Tkd_ptgs - Tnm - 6 TextBox Temp - Talmt - Ttelp - Tpas - ADODC PETUGAS PETUGAS komponen list name List1 Komonen Name Format Mask maskedbox tgl_lahir dd/mm/yyyy ##/##/#### 4 Frame Frame1 Frame2 Frame3 Frame4 Di kosongkan 2 OptionButton Op P Ol L
3) Atur tampilan form seperti gambar dibawah ini: Gambar 3 Form Input Data Petugas 4) Pengkodean pada form petugas Private Sub Form_Load() //menkoneksikan form ke data base pembayaran PETUGAS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB\pembayaran.mdb;Persist Security Info=False" PETUGAS.RecordSource = "select * from tpetugas" //menghuubungkan ke table petugas PETUGAS.Refresh Do While Not PETUGAS.Recordset.EOF // lakukan selama table tidak kosong List1.AddItem PETUGAS.Recordset!kd_ptgs //menampilkan isi kode petugas ke list1 PETUGAS.Recordset.MoveNext Loop Private Sub Form_Activate() PETUGAS.Visible = False // menonaktifkan ADODC petugas tkd_ptgs.setfocus // fokuskan saat form dijalan kan pada inputan kode petugas ttelp.maxlength = "12" // inputan telepon max 12 digit tpas.passwordchar = "*" // merubah inputan memjadi bintang cmdsimpan.enabled = False // menonaktifkan tombol simpan cmdhapus.enabled = False // menonaktifkan tombol hapus Private Sub tkd_ptgs_keypress(keyascii As Integer) //inputan kode petugas kosong atau bukan angka maka
If tkd_ptgs = "" Or Not IsNumeric(tkd_ptgs) Then // tampilkan pesan tkd_ptgs = "" // kosongkan inputan Tkd_ptgs tkd_ptgs.setfocus // jika inputan benar tnm.setfocus // fokuskan ke inputan tnm Private Sub tnm_keypress(keyascii As Integer) If tnm = "" Then // jika inputan tnm kosong MsgBox "Tidak Boleh", vbinformation, "InformASI" tnm.setfocus tnm = StrConv(tnm, vbpropercase) // merubah inputan menjadi huruf besar depannya ttemp.setfocus If KeyAscii > 47 And KeyAscii < 58 Then KeyAscii = 0 // kode menonaktifka tombol 0-9 Private Sub ttemp_keypress(keyascii As Integer) If ttemp = "" Then MsgBox "Tidak Boleh", vbinformation, "InformASI" ttemp.setfocus ttemp = StrConv(ttemp, vbuppercase) // merubah inputan menjadi huruf besar semua tgl_lahir.setfocus If KeyAscii > 47 And KeyAscii < 58 Then KeyAscii = 0 Private Sub tgl_lahir_keypress(keyascii As Integer) // jika inputan tanggal kosng atau bukan format tanggal If tgl_lahir = "" Or Not IsDate(tgl_lahir) Then MsgBox "Format tanggal salah", vbinformation, "Informasi" tgl_lahir.mask = "" tgl_lahir.text = "" tgl_lahir.mask = "##/##/####" tgl_lahir.setfocus
op.setfocus Private Sub op_keypress(keyascii As Integer) talmt.setfocus Private Sub ol_keypress(keyascii As Integer) talmt.setfocus Private Sub talmt_keypress(keyascii As Integer) Dim a As Integer // membuat variable a dengan tipe integer If talmt = "" Then talmt.setfocus // a samadengan pesan Yes atau No berupa pertanyan a = MsgBox("Apakah punya telepon", vbyesno + vbquestion, "Pertanyaan") If a = vbyes Then // jika punya telepon talmt = StrConv(talmt, vbpropercase) ttelp.setfocus // fokuskan ke inputan telepon // jika tidak talmt = StrConv(talmt, vbpropercase) tpas.setfocus // fokuskan ke inputan password Private Sub ttelp_keypress(keyascii As Integer) If ttelp = "" Or Not IsNumeric(ttelp) Then MsgBox "Inputan salah", vbinformation, "informasi" ttelp.setfocus tpas.setfocus
Private Sub tpas_keypress(keyascii As Integer) If tpas = "" Then MsgBox "Password harus diisi", vbinformation, "informasi" tpas.setfocus cmdsimpan.enabled = True cmdsimpan.setfocus Private Sub cmdsimpan_click() // menghubungkan ke tabel dengan kunci kd_ptgs pd tabel dan tkd_ptgs pd form PETUGAS.RecordSource = "select * from Tpetugas where kd_ptgs='" & tkd_ptgs & "'" PETUGAS.Refresh If PETUGAS.Recordset.EOF Then // jika tabel dalam keadaan kosong PETUGAS.Recordset.AddNew // menambah record baru // tambahkan inputan tkd_ptgs pd form ke record kd_ptgs pada tabel PETUGAS.Recordset!kd_ptgs = tkd_ptgs PETUGAS.Recordset!nama = tnm PETUGAS.Recordset!tempat = ttemp PETUGAS.Recordset!tgl_lahir = tgl_lahir If op = True Then // jika option pria di pilih maka PETUGAS.Recordset!jklm = "P" // simpan P PETUGAS.Recordset!jklm = "L" // 'jika tidak simpan L PETUGAS.Recordset!Alamat = talmt PETUGAS.Recordset!telepon = ttelp PETUGAS.Recordset!pass = tpas PETUGAS.Recordset.Update PETUGAS.Recordset.Clone // mengedit isi tabel PETUGAS.Recordset!kd_ptgs = tkd_ptgs PETUGAS.Recordset!nama = tnm PETUGAS.Recordset!tempat = ttemp PETUGAS.Recordset!tgl_lahir = tgl_lahir If op = True Then PETUGAS.Recordset!jklm = "P" PETUGAS.Recordset!jklm = "L" PETUGAS.Recordset!Alamat = talmt PETUGAS.Recordset!telepon = ttelp PETUGAS.Recordset!pass = tpas PETUGAS.Recordset.Update
Load Me Me.Show Private Sub cmdbatal_click() Load Me Me.Show Private Sub cmdhapus_click() Dim andi As Integer andi = MsgBox("Apakah petugas akan di hapus", vbquestion + vbyesno, "Konfirmasi") PETUGAS.RecordSource = "select * from Tpetugas where kd_ptgs='" & tkd_ptgs & "'" PETUGAS.Refresh If Not PETUGAS.Recordset.EOF Then If andi = vbyes Then PETUGAS.Recordset.Delete PETUGAS.Recordset.MoveFirst Load Me Me.Show Load Me Me.Show Private Sub cmdkeluar_click() Private Sub cmdcari_click() PETUGAS.RecordSource = "select * from Tpetugas where kd_ptgs='" & tkd_ptgs & "'" PETUGAS.Refresh If Not PETUGAS.Recordset.EOF Then tnm = PETUGAS.Recordset!nama ttemp = PETUGAS.Recordset!tempat tgl_lahir = Format(PETUGAS.Recordset!tgl_lahir = tgl_lahir, "dd/mm/yyyy") If PETUGAS.Recordset!jklm = "P" Then op = True ol = True talmt = PETUGAS.Recordset!Alamat
ttelp = PETUGAS.Recordset!telepon tpas = PETUGAS.Recordset!pass cmdsimpan.enabled = True cmdhapus.enabled = True MsgBox "Data tidak terdaftar", vbinformation, "Informasi" Load Me Me.Show Private Sub List1_Click() PETUGAS.RecordSource = "select * from Tpetugas where kd_ptgs='" & List1 & "'" PETUGAS.Refresh If Not PETUGAS.Recordset.EOF Then tkd_ptgs = PETUGAS.Recordset!kd_ptgs tnm = PETUGAS.Recordset!nama ttemp = PETUGAS.Recordset!tempat tgl_lahir = Format(PETUGAS.Recordset!tgl_lahir = tgl_lahir, "dd/mm/yyyy") If PETUGAS.Recordset!jklm = "P" Then op = True ol = True talmt = PETUGAS.Recordset!Alamat ttelp = PETUGAS.Recordset!telepon tpas = PETUGAS.Recordset!pass cmdsimpan.enabled = True cmdhapus.enabled = True B. Pembuatan input data siswa 1) Membuat table siswa Buat table dengan nama Tsiswa buat isi table seperti gambar di bawah ini Field name Data type Field size Index nis Text 4 Primary key nama Text 25 - tempat Text 15 - tgl_lahir Date/Time - - jklm Text 2 - alamat Text 40 - kelas Text 4 - telepon Text 12 -
Gambar 4 Table Siswa 2) Komponen-komponen yang digunakan dalam pembuatan form inpit data siswa 1 form Frm_Siswa Input Data Siswa Auto Zize Nis Nama Tempat/Tgl/Lahir 7 Label Tidak dirubah Jenis Kelamin True Alamat Kelas Telepon Cmdsimpan &SIMPAN Cmdbatal &BATAL 5 commondbutton Cmdhapus &HAPUS Cmdkeluar &KELUAR Komponen Name Text Tnis - Tnm - 6 TextBox Temp - Talmt - Ttelp - ADODC SISWA SISWA komponen list name lissiswa Komonen Name Format Mask maskedbox tgl_lahir dd/mm/yyyy ##/##/####
4 Frame Frame1 Frame2 Frame3 Frame4 Di kosongkan 2 OptionButton Oput Putra Otri Putri 3) Atur tampilan form seperti gambar dibawah ini. Gambar 5 Form Input Data Siswa 4) Pengkodean pada form input data siswa Private Sub Form_Activate() tnis.setfocus Private Sub Form_Load() SISWA.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB\pembayaran.mdb;Persist Security Info=False" SISWA.RecordSource = "select * from Tsiswa" SISWA.Refresh Do While Not SISWA.Recordset.EOF Lissiswa.AddItem SISWA.Recordset!nis SISWA.Recordset.MoveNext Loop comkls.additem "Satu"
comkls.additem "Dua" comkls.additem "Tiga" cmdsimpan.enabled = False cmdhapus.enabled = False Sub simpan() With SISWA.Recordset!nis = tnis!nama = tnm!tempat = ttemp!tgl_lahir = tgl_lahir If Oput = True Then!jklm = "Putra"!jklm = "Putri"!Alamat = talmt!kelas = comkls!telpon = ttelp.update End With Sub tampil() With SISWA.Recordset tnis =!nis tnm =!nama ttemp =!tempat tgl_lahir =!tgl_lahir If!jklm = "Putra" Then Oput = True Otri = True talmt =!Alamat comkls =!kelas ttelp =!telpon End With Sub kosong() Load Me Me.Show
Sub TidakAda() tnm = Empty ttemp = Empty tgl_lahir.mask = Empty tgl_lahir.text = Empty tgl_lahir.mask = "##/##/####" Oput = False Otri = False talmt = Empty comkls = Empty ttelp = Empty tfoto = Empty Private Sub tnis_keypress(keyascii As Integer) If tnis = "" Or Not IsNumeric(tnis) Then tnis = "" SISWA.RecordSource = "select * from Tsiswa where nis='" & tnis & "'" SISWA.Refresh If Not SISWA.Recordset.EOF Then tampil tgl_lahir = Format(Date, "dd/mm/yyyy") cmdsimpan.enabled = True cmdsimpan.caption = "&EDIT" cmdhapus.enabled = True TidakAda cmdsimpan.enabled = False cmdhapus.enabled = False cmdsimpan.caption = "&SIMPAN" tnm.enabled = True tnm.setfocus Private Sub tnm_keypress(keyascii As Integer) If tnm = "" Or IsNumeric(tnm) Then tnm = "" tnm = StrConv(tnm, vbpropercase) ttemp.setfocus
If KeyAscii > 47 And KeyAscii < 58 Then KeyAscii = 0 Private Sub ttemp_keypress(keyascii As Integer) If ttemp = "" Or IsNumeric(ttemp) Then ttemp = "" ttemp = StrConv(ttemp, vbpropercase) tgl_lahir.setfocus If KeyAscii > 47 And KeyAscii < 58 Then KeyAscii = 0 Private Sub tgl_lahir_keypress(keyascii As Integer) If tgl_lahir = "" Or Not IsDate(tgl_lahir) Then tgl_lahir.mask = Empty tgl_lahir.text = Empty tgl_lahir.mask = "##/##/####" Oput.SetFocus Private Sub Oput_KeyPress(KeyAscii As Integer) talmt.setfocus Private Sub Otri_KeyPress(KeyAscii As Integer) talmt.setfocus Private Sub talmt_keypress(keyascii As Integer) If talmt = "" Then talmt = StrConv(talmt, vbpropercase) comkls.setfocus
Private Sub comkls_keypress(keyascii As Integer) If comkls = "" Or comkls.listindex = -1 Then MsgBox "Tidak Boleh, Tekan Panah Bawah Untuk Memilih", vbinformation, "Informasi" comkls = "" Dim a As Integer a = MsgBox("Apakah Punya No telpon", vbyesno + vbquestion, "Pertanyaan") If a = vbyes Then ttelp.setfocus cmdsimpan.enabled = True cmdsimpan.setfocus Private Sub ttelp_keypress(keyascii As Integer) If ttelp = "" Or Not IsNumeric(ttelp) Then ttelp = "" cmdsimpan.enabled = True cmdsimpan.setfocus Private Sub cmdsimpan_click() SISWA.RecordSource = "select * from Tsiswa where nis='" & tnis & "'" SISWA.Refresh If Not SISWA.Recordset.EOF Then SISWA.Recordset.Clone simpan kosong SISWA.Recordset.AddNew simpan kosong
Private Sub cmdbatal_click() kosong Private Sub cmdhapus_click() SISWA.RecordSource = "select * from Tsiswa where nis='" & tnis & "'" SISWA.Refresh If Not SISWA.Recordset.EOF Then SISWA.Recordset.Delete SISWA.Recordset.MoveFirst kosong Private Sub cmdhapus_click() SISWA.RecordSource = "select * from Tsiswa where nis='" & tnis & "'" SISWA.Refresh If Not SISWA.Recordset.EOF Then SISWA.Recordset.Delete SISWA.Recordset.MoveFirst kosong Private Sub cmdkeluar_click() 5) 6) Vfdgsg 7) C. Pembuatan input jenis pembayran D. Pembuatan form transaksi