1. Tombol Simpan
Private Sub
Command1_Click()
Set RS = New
ADODB.Recordset
If Combo2.Text =
"" Then
MsgBox "Data Tidak Boleh Kosong",
vbCritical, "Peringatan!"
Combo2.SetFocus
ElseIf Text4.Text = "" Then
MsgBox "Harga Beli Harus Di Isi",
vbCritical, "Peringatan!"
Text4.SetFocus
Else
RS.Open
"Select * from barang where Kode_Brg = '" & Combo2.Text &
"'", CON, adOpenDynamic, adLockOptimistic
If Not RS.EOF Then
MsgBox "Data Sudah Ada!!!",
vbCritical, "Peringatan!"
Combo2.SetFocus
Else
RS.AddNew
RS.Fields("Kode_Brg")
= Combo2.Text
RS.Fields("Harga_Jual")
= Text4.Text
RS.Update
MsgBox "DATA
TERSIMPAN", vbInformation, "Informasi"
bersih
tabel
Combo2.SetFocus
End If
End If
End Sub
2. Edit
Private Sub
Command2_Click()
Set RS = New
ADODB.Recordset
RS.Open
"Select * From barang WHERE Kode_Brg = '" & Combo2.Text &
"'", CON, adOpenDynamic, adLockOptimistic
If Not RS.EOF Then
RS.Fields("Kode_Brg")
= Combo2.Text
RS.Fields("Harga_Jual")
= Text4.Text
RS.Update
MsgBox "DATA
TELAH DIROBAH", vbInformation, "Informasi"
bersih
tabel
Combo2.SetFocus
End If
End Sub
3. Keluar
Private Sub
Command5_Click()
X =
MsgBox("Yakin Data Dihapus...??", vbQuestion + vbYesNo,
"Informasi")
If X = vbYes Then
Set RS = New
ADODB.Recordset
RS.Open
"Delete From Barang Where Kode_Brg = '" & Text5.Text &
"'", CON, adOpenDynamic, adLockOptimistic
bersih
tabel
Combo2.SetFocus
End If
End Sub
PRINT DATA
Private Sub
Command7_Click()
CR.ReportFileName =
App.Path & "\Data_Barang.rpt"
CR.RetrieveDataFiles
CR.WindowState =
crptMaximized
CR.Action = 0
End Sub
4. Keluar
Private Sub
Command3_Click()
T =
MsgBox("anda yakin ingin keluar dari form!!!", vbQuestion + vbYesNo,
"informasi")
If T = vbYes Then
Unload Me
End If
End Sub
UNLOAD ME digunakan
untuk keluar dari satu form saja
END digunakan untuk
keluar dari program

Tidak ada komentar:
Posting Komentar