Option Explicit
Dim objConnection
Dim objRecordset
Dim statuus As String
Dim databaseName As String
Dim Dirubah As Integer
Private Sub Combo1_Click()
showName Combo1.ListIndex
end sub
Private cmdDelete_Click()
Dim As Integer
a = MsgBox("Apakah anda yakin ingin menghapus data ini??",vbYesNo + vbQuestion, App.Title)
If a = vbYes Then
ObjRecordset.Open "DELETE FROM data WHERE nama'" & txtTanggal.Text & "' AND id=" & resolveld(Combo.ListIndex), databaseName, 2, 3
txtTanggal.Text = ""
txtJml_HrMengendap.Text = ""
txtJns_Tran.Text = ""
txtMuTasi.Text = ""
txtSaldo.Text = ""
UpdateCombo
End If
End Sub
Private CmdEdit_Click()
cmdSave.Enabled = True
cmdNew.Enabled = False
cmdEdit.Enabled = False
cmdDelete.Enabled = False
Combo1.Enabled = False
statuus = "ubah"
Dirubah = resolveld(Combo1.ListIndex)
txtTanggal.Locked = False
txtJml_HrMengendap.Locked = False
txtJns_Tran.Locked = False
txtMuTasi.Locked = False
txtSaldo.Locked = False
End Sub
Private Sub cmdNew_Click()
txtTanggal.Text = ""
txtJml_HrMengendap.Text = ""
txtJns_Tran.Text = ""
txtMuTasi.Text = ""
txtSaldo.Text = ""
txtTanggal.Locked = False
txtJml_HrMengendap.Locked = False
txtJns_Tran.Locked = False
txtMuTasi.Locked = False
txtSaldo.Locked = False
cmdSave.Enabled = True
cmdNew.Enabled = False
cmdEdit.Enabled = False
cmdDelete.Enabled = False
Combo1.Enabled = False
statuus = "ubah"
End Sub
Private Sub cmdSave_Click()
Dim skarang As Integer
If txtTanggal.Text <> "" Then
If statuus = "baru" Then
objRecordset.Open "SELECT id FROM data ORDER BY id ASC",databaseName, 2, 3
If ObjRecordset.RecordCount > 0 Then
objRecordset.MoveLast
skarang = objRecordset.Fields("id") + 1
Else
skarang = 1
End If
objRecordset.Close
objRecordset.Open "SELECT * FROM data", databaseName, 2, 3
objRecordset.AddNew
objRecordset.Fields("id") = skarang
Else
objRecordset.Open "SELECT * FROM data WHERe id=" & Diubah, databaseName, 2, 3
End If
objRecordset.Fields("Tanggal") = txtTanggal.Text
objRecordset.Fields("Jml_HrMengendap") = txtJml_HrMengendap.Text
objRecordset.Fields("Jns_Tran") = txtJns_Tran.Text
objRecordset.Fields("MuTasi") = txtMuTasi.Text
objRecordset.Fields("Saldo") = txtSaldo.Text
objRecordset.Update
objRecordset.close
MsgBox "DAta berhasil disimpan", vbOKOnly, App.Title
cmdSave.Enabled = False
cmdNew.Enabled = True
cmdEdit.Enabled = True
cmdDelete.Enabled = True
Combo1.Enabled = True
UpdateCombo
Else
MgsBox "Silahkan masukkan Tanggal-nya", vbOKOnly + vbCritical, App.Title
End If
txtTanggal.Locked = True
txtJml_HrMengendap.Locked = True
txtJns_Tran.Locked = True
txtMuTasi.Locked = True
txtSaldo.Locked = True
End Sub
Private Sub Form_Load()
databaseName = App.Path & "D:\Tgs Perbankan\Transaksi Rekening1.mdb"
On Error Resume Next
Set objRecordset = CreateObject("ADOCE.Recordset.3.0")
UpdateCombo
objRecordset.Open "CREATE TABLE data(id int,Tanggal Varchar(10),Jml_HrMenginap Varchar(5),Jns_Tran Varchar(6),Mutasi Varchar(8),Saldo Varchar(8))", databaseName, 2, 3
End Sub
Private Sub Form_OKClick()
Set objRecordset = Nothing
App.End
End Sub
Private Sub UpdateCombo()
Combo1.Clear
objRecordset.Open "SELECT * FROM data ORDER BY Tanggal", databaseName, 2, 3
If objRecordset.RecordCount > 0 Then
Do
Combo1.AddItem objRecordset.Fields("Combo1")
objRecordset.MoveNext
Loop Until objRecordset.EOF = True
End If
objRecordset.Close
If Combo1.ListCount > 0 Then
Combo1.ListIndex = 0
showName (0)
End If
End Sub
Private Sub showName(indexNama As Integer)
If resolveld(indexNama) <> 0 Then
objRecordset.Open "SELECT * FROM data WHERe id=" & resolveld(indexNama), databaseName, 2, 3
If resolveld(indexNama) > 0 Then
txtTanggal.Text = objRecordset.Fields("Tanggal")
txtJml_HrMengendap.Text = objRecordset.Fields("Jml_HrMengendap")
txtJns_Tran.Text = objRecordset.Fields("Jns_Tran")
txtMuTasi.Text = objRecordset.Fields("MuTasi")
txtSaldo.Text = objRecordset.Fields("Saldo")
End If
objRecordset.Close
End If
End Sub
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar