Setelah kita melihat contoh Program Visual Basic (VB) Penerimaan karyawan baru (Employee Recruitment). Maka Selanjutnya kita Membuat Penginputan tanggal tes medical pada program peneimaan karyawan baru di Ms Visual Basic dengan database Mysql phpmyadmin.
Ubah name nya seperti dibawah ini :
- Buatlah sub aktif :
Sub aktif()
tglmedical.Enabled = True
tglfisik.Enabled = True
End Sub
tglmedical.Enabled = True
tglfisik.Enabled = True
End Sub
- Buatlah sub nonaktif :
Sub nonaktif()
nokode.Enabled = False
tglmedical.Enabled = False
tglfisik.Enabled = False
tcari.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdedit.Enabled = False
cmdupdate.Enabled = False
cmddelete.Enabled = False
End Sub
nokode.Enabled = False
tglmedical.Enabled = False
tglfisik.Enabled = False
tcari.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdedit.Enabled = False
cmdupdate.Enabled = False
cmddelete.Enabled = False
End Sub
- Buat sub tampil :
Sub tampil()
Call koneksi
rstanggalmedical.Open "select*from tanggalmedicaltest", KON
Set grid.DataSource = rstanggalmedical
End Sub
\Call koneksi
rstanggalmedical.Open "select*from tanggalmedicaltest", KON
Set grid.DataSource = rstanggalmedical
End Sub
- Sub bersih :
Sub bersih()
tglmedical.Text = ""
tglfisik.Text = ""
tcari.Text = ""
nokode.Text = ""
End Sub
- Buat form load :
Private Sub Form_Load()
Call nonaktif
cmdadd.Enabled = True
End Sub
Call nonaktif
cmdadd.Enabled = True
End Sub
Selanjutnya pastekan kode berikutpada "commandbutton" dengan name yg telah di ubah :
- cmdadd :
Private Sub cmdadd_Click()
Call koneksi
Call bersih
Call aktif
rstanggalmedical.Open "select*from tanggalmedicaltest order by no_kode desc", KON
With rstanggalmedical
If .BOF And .EOF Then
nokode.Text = "TM" + "001"
Else
nokode.Text = "TM" + Right(Str(Val(Right(.Fields("no_kode"), 3)) + 1001), 3)
End If
End With
tglmedical.SetFocus
cmdsave.Enabled = True
cmdcancel.Enabled = True
cmddelete.Enabled = False
tcari.Enabled = True
End Sub
Call koneksi
Call bersih
Call aktif
rstanggalmedical.Open "select*from tanggalmedicaltest order by no_kode desc", KON
With rstanggalmedical
If .BOF And .EOF Then
nokode.Text = "TM" + "001"
Else
nokode.Text = "TM" + Right(Str(Val(Right(.Fields("no_kode"), 3)) + 1001), 3)
End If
End With
tglmedical.SetFocus
cmdsave.Enabled = True
cmdcancel.Enabled = True
cmddelete.Enabled = False
tcari.Enabled = True
End Sub
- cmdsave :
Private Sub cmdsave_Click()
Call koneksi
rstanggalmedical.Open "insert into tanggalmedicaltest values('" & nokode & "','" & tglmedical & "','" & tglfisik & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call nonaktif
End Sub
Call koneksi
rstanggalmedical.Open "insert into tanggalmedicaltest values('" & nokode & "','" & tglmedical & "','" & tglfisik & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call nonaktif
End Sub
- cmdcancel :
Private Sub cmdcancel_Click()
bersih
tglmedical.SetFocus
Call nonaktif
cmdadd.Enabled = True
End Sub
- cmddelete :
Private Sub cmddelete_Click()
Call koneksi
a = MsgBox("Yakin Ingin Hapus Data ini?", vbQuestion + vbYesNo, "tanya")
If a = vbYes Then
rstanggalmedical.Open "delete from tanggalmedicaltest where no_kode='" & tcari.Text & "'", KON
bersih
tcari.Text = ""
End If
End Sub
- cmdedit:
Private Sub cmdedit_Click()
Call koneksi
rstanggalmedical.Open "select*from tanggalmedicaltest where no_kode='" & tcari.Text & "'", KON
With rstanggalmedical
nokode.Text = .Fields("no_kode")
tglmedical.Text = .Fields("tanggalmedicaltest")
tglfisik.Text = .Fields("tanggalfisiktest")
End With
nokode.Enabled = False
tglmedical.SetFocus
cmdupdate.Enabled = True
cmddelete.Enabled = True
cmdcancel.Enabled = False
End Sub
Call koneksi
rstanggalmedical.Open "select*from tanggalmedicaltest where no_kode='" & tcari.Text & "'", KON
With rstanggalmedical
nokode.Text = .Fields("no_kode")
tglmedical.Text = .Fields("tanggalmedicaltest")
tglfisik.Text = .Fields("tanggalfisiktest")
End With
nokode.Enabled = False
tglmedical.SetFocus
cmdupdate.Enabled = True
cmddelete.Enabled = True
cmdcancel.Enabled = False
End Sub
--cmdupdate :
Private Sub cmdupdate_Click()
Call koneksi
rstanggalmedical.Open "update tanggalmedicaltest set tanggalmedicaltest='" & tglmedical & "',tanggalfisiktest='" & tglfisik & "' where no_kode='" & nokode.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
cmdupdate.Enabled = False
cmdedit.Enabled = False
cmdadd.Enabled = True
End Sub
Call koneksi
rstanggalmedical.Open "update tanggalmedicaltest set tanggalmedicaltest='" & tglmedical & "',tanggalfisiktest='" & tglfisik & "' where no_kode='" & nokode.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
cmdupdate.Enabled = False
cmdedit.Enabled = False
cmdadd.Enabled = True
End Sub
- tcari (ubah delarationsnya ke "change") :
Private Sub tcari_Change()
Call koneksi
rstanggalmedical.Open "select*from tanggalmedicaltest where no_kode like '" & tcari.Text & "'", KON
If Not tcari.Text = "" Then
Set grid.DataSource = rstanggalmedical
Else
Call tampil
End If
tcari.Enabled = True
cmdedit.Enabled = True
cmddelete.Enabled = True
cmdadd.Enabled = False
cmdsave.Enabled = False
End Sub
Call koneksi
rstanggalmedical.Open "select*from tanggalmedicaltest where no_kode like '" & tcari.Text & "'", KON
If Not tcari.Text = "" Then
Set grid.DataSource = rstanggalmedical
Else
Call tampil
End If
tcari.Enabled = True
cmdedit.Enabled = True
cmddelete.Enabled = True
cmdadd.Enabled = False
cmdsave.Enabled = False
End Sub
- bmenu :
Private Sub Command1_Click()
fmenu.Show
End Sub
- exit :
Private Sub EXIT_Click()
a = MsgBox("Yakin Keluar", vbCritical + vbYesNo, "INFO")
If a = vbYes Then
End
End If
End Sub
a = MsgBox("Yakin Keluar", vbCritical + vbYesNo, "INFO")
If a = vbYes Then
End
End If
End Sub
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :