Form Data
Form data adalah form untuk input data dan menampilkan data yang telah tersimpan dalam database
design
terdiri dari
coding
Sub refreshDG()
Set rsKoleksi = New ADODB.Recordset
rsKoleksi.LockType = adLockOptimistic
rsKoleksi.CursorType = adOpenDynamic
rsKoleksi.Open "SELECT * FROM Koleksi", conn, , , adCmdText
Set DGku.DataSource = rsKoleksi
End Sub
Sub clearTxt()
txtNama.Text = ""
txtJenis.Text = ""
txtTahun.Text = ""
txtJumlah.Text = ""
txtNama.SetFocus
End Sub
Private Sub cmdSave_Click()
Dim tanya
tanya = MsgBox("Apakah Data Telah Diisi Lengkap?", vbQuestion + vbYesNo)
If tanya = vbYes Then
Set rsKoleksi = New ADODB.Recordset
rsKoleksi.LockType = adLockOptimistic
rsKoleksi.CursorType = adOpenDynamic
rsKoleksi.Open "SELECT * FROM Koleksi", conn, , , adCmdText
With rsKoleksi
.AddNew
!Nama = txtNama.Text
!Jenis = txtJenis.Text
!Jumlah = txtJumlah.Text
!Tahun = Int(txtTahun.Text)
.Update
End With
MsgBox "Data Tersimpan", vbInformation
refreshDG
clearTxt
Else
clearTxt
End If
End Sub
Private Sub Form_Load()
koneksi_db
refreshDG
End Sub
design
terdiri dari
- 1 buah form
- 4 buah label
- 4 buah text box
- 2 buah tombol
- 1 buah datagrid
coding
Sub refreshDG()
Set rsKoleksi = New ADODB.Recordset
rsKoleksi.LockType = adLockOptimistic
rsKoleksi.CursorType = adOpenDynamic
rsKoleksi.Open "SELECT * FROM Koleksi", conn, , , adCmdText
Set DGku.DataSource = rsKoleksi
End Sub
Sub clearTxt()
txtNama.Text = ""
txtJenis.Text = ""
txtTahun.Text = ""
txtJumlah.Text = ""
txtNama.SetFocus
End Sub
Private Sub cmdSave_Click()
Dim tanya
tanya = MsgBox("Apakah Data Telah Diisi Lengkap?", vbQuestion + vbYesNo)
If tanya = vbYes Then
Set rsKoleksi = New ADODB.Recordset
rsKoleksi.LockType = adLockOptimistic
rsKoleksi.CursorType = adOpenDynamic
rsKoleksi.Open "SELECT * FROM Koleksi", conn, , , adCmdText
With rsKoleksi
.AddNew
!Nama = txtNama.Text
!Jenis = txtJenis.Text
!Jumlah = txtJumlah.Text
!Tahun = Int(txtTahun.Text)
.Update
End With
MsgBox "Data Tersimpan", vbInformation
refreshDG
clearTxt
Else
clearTxt
End If
End Sub
Private Sub Form_Load()
koneksi_db
refreshDG
End Sub
Comments
Post a Comment