Ass. Wr. Wb
Wah asyik penjelasannya.. Kang
Tapi ada yang kurang jelas..!
1. Untuk VBA di listview nya kumaha ...
2. Makdud di edit adalah ketika kita menambah atau mengurangi item di listview..
akan merubah data tabel transdet..
Nuhun Pisan.. tong kapok..
Wass
DSW
From: Sofyan Efendi <sofyanefendi@gmail.com>
To: belajar-access@yahoogroups.com
Sent: Wednesday, May 30, 2012 10:05 AM
Subject: Re: [belajar-access] VBA listview Lagi [1 Attachment]
Dear Kang Dani, kita bisa manfaatkan ADO dan DAO untuk penggunaan data unbound.
Deklarasikan dahulu di paling atas class modulenya, variable recordset dan databasenya. Karena Kang Dani menggunakan DAO, kita bisa menggunakan (misal):
Option Compare Database
Private dbtmp As DAO.Database
Private rstmp As DAO.Recordset
Private dbtmp As DAO.Database
Private rstmp As DAO.Recordset
Pada event On Load, isi variable diatas, misal:
Private Sub Form_Load()
' DoCmd.Maximize
Call IsiListView
Call VIEW
' DoCmd.Maximize
Call IsiListView
Call VIEW
' Tambahan dari Opi, isi memori variable dengan recordset yg kita inginkan:
Set dbtmp = CurrentDb()
Set rstmp = dbtmp.OpenRecordset("SELECT DISTINCTROW Trans.*, TransDet.* FROM Trans INNER JOIN TransDet ON Trans.IDTrans = TransDet.IDTrans;", dbOpenDynaset)
Set Me.Recordset = rstmp
End Sub
Set dbtmp = CurrentDb()
Set rstmp = dbtmp.OpenRecordset("SELECT DISTINCTROW Trans.*, TransDet.* FROM Trans INNER JOIN TransDet ON Trans.IDTrans = TransDet.IDTrans;", dbOpenDynaset)
Set Me.Recordset = rstmp
End Sub
Kemudian untuk tombol Next Record:
Private Sub Command106_Click()
On Error GoTo nol
Me.Recordset.MoveNext
Me.Noreg = rstmp!Noreg
Me.Nama = rstmp!Nama
Me.Alamat = rstmp!Alamat
nol:
End Sub
On Error GoTo nol
Me.Recordset.MoveNext
Me.Noreg = rstmp!Noreg
Me.Nama = rstmp!Nama
Me.Alamat = rstmp!Alamat
nol:
End Sub
Untuk previous:
Private Sub Command105_Click()
On Error GoTo nol
Me.Recordset.MovePrevious
Me.Noreg = rstmp!Noreg
Me.Nama = rstmp!Nama
Me.Alamat = rstmp!Alamat
nol:
End Sub
On Error GoTo nol
Me.Recordset.MovePrevious
Me.Noreg = rstmp!Noreg
Me.Nama = rstmp!Nama
Me.Alamat = rstmp!Alamat
nol:
End Sub
Adapun yg dimaksud membuka ulang (edit) record yg sudah di simpan bagaimana ya Kang? Mengapa tidak menggunakan satu perintah "Simpan" saja ya? Kan datanya sudah tampil, tidak perlu menggunakan tombol Edit, karena sudah bisa langsung di Edit. Jadi tinggal klik Simpan saja menurut saya.
Private Sub Simpan_Click()
'===========================
'Tambahan dari Opi:
rstmp.Edit
rstmp!Noreg = Me.Noreg
rstmp!Nama = Me.Nama
rstmp!Alamat = Me.Alamat
rstmp.Update
'===========================
'===========================
'Tambahan dari Opi:
rstmp.Edit
rstmp!Noreg = Me.Noreg
rstmp!Nama = Me.Nama
rstmp!Alamat = Me.Alamat
rstmp.Update
'===========================
Dim db As Database
Dim rs As Recordset
Dim ra As Recordset
Set db = CurrentDb()
Set ra = db.OpenRecordset("Trans", dbOpenDynaset)
Set rs = db.OpenRecordset("Transdet", dbOpenDynaset)
Dim i As Long
Dim rs As Recordset
Dim ra As Recordset
Set db = CurrentDb()
Set ra = db.OpenRecordset("Trans", dbOpenDynaset)
Set rs = db.OpenRecordset("Transdet", dbOpenDynaset)
Dim i As Long
ra.AddNew
If DCount("idtrans", "trans", "[idtrans] Like '*'") = 0 Then
nourut = 1
Else
NoUrutTertinggi = CInt(DMax("idtrans", "trans", "[idtrans] Like '*'"))
nourut = NoUrutTertinggi + 1
End If
If DCount("idtrans", "trans", "[idtrans] Like '*'") = 0 Then
nourut = 1
Else
NoUrutTertinggi = CInt(DMax("idtrans", "trans", "[idtrans] Like '*'"))
nourut = NoUrutTertinggi + 1
End If
ra!idtrans = nourut
ra!Noreg = Me.Noreg
ra!Nama = Me.Nama
ra!Alamat = Me.Alamat
ra.Update
For i = 1 To ListViewLAB.ListItems.Count
If ListViewLAB.ListItems(i).Checked = True Then
rs.AddNew
rs!idtrans = intnourut
rs!kode = ListViewLAB.ListItems(i).Text
rs!barang = ListViewLAB.ListItems(i).SubItems(1)
rs!harga = ListViewLAB.ListItems(i).SubItems(2)
rs!model = ListViewLAB.ListItems(i).SubItems(3)
rs.Update
End If
Next i
Me!SumHarga = Format(Me!SumHarga, "#,###")
ra!Noreg = Me.Noreg
ra!Nama = Me.Nama
ra!Alamat = Me.Alamat
ra.Update
For i = 1 To ListViewLAB.ListItems.Count
If ListViewLAB.ListItems(i).Checked = True Then
rs.AddNew
rs!idtrans = intnourut
rs!kode = ListViewLAB.ListItems(i).Text
rs!barang = ListViewLAB.ListItems(i).SubItems(1)
rs!harga = ListViewLAB.ListItems(i).SubItems(2)
rs!model = ListViewLAB.ListItems(i).SubItems(3)
rs.Update
End If
Next i
Me!SumHarga = Format(Me!SumHarga, "#,###")
rs.Close
Set rs = Nothing
ra.Close
Set ra = Nothing
db.Close
Set db = Nothing
Set rs = Nothing
ra.Close
Set ra = Nothing
db.Close
Set db = Nothing
End Sub
Kemudian jangan lupa untuk membersihkan memori saat form di close:
Private Sub Form_Close()
rstmp.Close
dbtmp.Close
Set rstmp = Nothing
Set dbtmp = Nothing
End Sub
rstmp.Close
dbtmp.Close
Set rstmp = Nothing
Set dbtmp = Nothing
End Sub
Saya kirim balik ya attach file nya. Silahkan buka form "EDIT". Trim's.
Wassalaamu'alaikum Warahmatullahi Wabarakatuh,
Sofyan Efendi
http://imopi.wordpress.com/
Sofyan Efendi
http://imopi.wordpress.com/
----- Original Message -----From: dani wardanaSent: Tuesday, May 29, 2012 9:13 AMSubject: [belajar-access] VBA listview Lagi [1 Attachment]Ass.Wr.WbMaster Access sekalian..
minta pencerahan VBA nya untuk
1. membuka ulang (edit) record yg sudah di simpan
2. membuat VBA untuk maju / mundur record..
terima kasih sebelumnya
wass
DSW
__._,_.___
SPAM IS PROHIBITED
.
__,_._,___
Tidak ada komentar:
Posting Komentar