0% found this document useful (0 votes)
36 views2 pages

Kita Buat Tombol Editnya, Caranya Double Klik Pada Tombol Edit Dan Masukkan Script Berikut Diantara Dengan

The document contains code for creating buttons to save, edit, delete, and exit data from a form in Visual Basic. It includes code to check that all fields are filled before saving, display a confirmation message before saving or editing, update the record after editing, delete the selected record, and confirm before exiting the form.

Uploaded by

altgifi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Kita Buat Tombol Editnya, Caranya Double Klik Pada Tombol Edit Dan Masukkan Script Berikut Diantara Dengan

The document contains code for creating buttons to save, edit, delete, and exit data from a form in Visual Basic. It includes code to check that all fields are filled before saving, display a confirmation message before saving or editing, update the record after editing, delete the selected record, and confirm before exiting the form.

Uploaded by

altgifi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Tombol simpan; Dim X If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.

Text = "" Or Text7.Text = "" Then MsgBox "Data Belum Lengkap", vbInformation, "Pesan" Exit Sub Else X = MsgBox("Apakah Data Ingin Disimpan...?", vbQuestion + vbYesNo) If X = vbYes Then Set rsmhs = New ADODB.Recordset rsmhs.LockType = adLockOptimistic rsmhs.CursorType = adOpenDynamic rsmhs.Open "SELECT * FROM tmhs", conn, , , adCmdText rsmhs.AddNew rsmhs.Fields(0) = Text1.Text rsmhs.Fields(1) = Text2.Text rsmhs.Fields(2) = Text3.Text rsmhs.Fields(3) = Text4.Text rsmhs.Fields(4) = Text5.Text rsmhs.Fields(5) = Text6.Text rsmhs.Fields(6) = Text7.Text rsmhs.Update MsgBox "Data Tersimpan...!", vbInformation, "Pesan" kosongform Else Exit Sub End If End If

kita buat tombol Editnya, caranya double klik pada tombol Edit dan masukkan script berikut diantara Private Sub Command2_Click() dengan End Sub.

Dim a a = MsgBox("Edit Data...?", vbQuestion + vbYesNo, "Pesan") If a = vbYes Then rsmhs.Fields(1) = Text2.Text rsmhs.Fields(2) = Text3.Text rsmhs.Fields(3) = Text4.Text rsmhs.Fields(4) = Text5.Text rsmhs.Fields(5) = Text6.Text rsmhs.Fields(6) = Text7.Text rsmhs.Update

MsgBox "Data Berhasil Di Edit..!!", vbInformation, "Info" kosongform Text1.SetFocus Else Exit Sub End If Selanjutnya, kita buat tombol Delete, Caranya double klik pada tombol Delete dan masukkan script berikut diantara Private Sub Command3_Click() dengan End Sub. Dim Y Y = MsgBox("Apakah Data Ingin Dihapus..?", vbQuestion + vbYesNo) If Y = vbYes Then rsmhs.Delete MsgBox "Data Berhasil Dihapus..!!", vbInformation, "info" kosongform Text1.SetFocus Else Exit Sub End If Terakhir, kita buat tombol Exit, duoble klik pada tombol Exit dan masukkan script berikut diantara Private Sub Command4_Click() dengan End Sub. Dim X X = MsgBox("Apakah Anda Ingin Keluar..?", vbQuestion + vbYesNo, App.Title) If X = vbYes Then Unload Me Else Cancel = 1 End If

You might also like