Moed,
Karena Access gak ada store procedure, jadi kita simulasikan store
procedurenya lewat vba.
saya bikin temp. table zTable1 yang sama persis strukturnya dengan Table1
(nama saya ganti, bikinnya buru-buru :) )
lalu zTable1 saya buatkan form datasheet untuk melihat hasilnya.
di setiap kali buka form, ztable1 selalu dipaksa untuk mengupdate, mengambil
dari table1 3 baris pertama setiap departemen.
code behind form form1:
Option Compare Database
Option Explicit
Sub RefreshData()
Dim rs As DAO.Recordset
CurrentDb.Execute "DELETE * FROM zTable1"
DoEvents
Set rs = CurrentDb.OpenRecordset("SELECT Dept FROM Table1 GROUP BY
Dept")
rs.MoveFirst
Do While Not rs.EOF
CurrentDb.Execute "INSERT INTO zTable1 (Dept, Amount) SELECT TOP 3
Dept, Amount FROM Table1 WHERE Dept = '" & Nz(rs(0), "") & "'"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Me.Requery
End Sub
Private Sub Form_Open(Cancel As Integer)
RefreshData
End Sub
Idenya seperti itu, tinggal mahmoed kembangin sesuai kebutuhan.
Untuk membentuk dalam satu query, saya belum bisa.
aksan kurdin
2008/6/24 Ivan Leonardo <[EMAIL PROTECTED]>:
> Oh iya ya saya kurang teliti, nah kalo kaya gitu ribet nih rumit emang.
> Yg terpikir oleh saya cuman cara ini :
> 1. mesti buat temp tbl yg isinya seluruh data yg mau di pilih, lalu
> tambahkan kolom nourut jenis number byte
> 2. buat coding vba utk isi nourut masing2 jenis grup, contoh :
> a. open recordset tbl-temp order by group (ascending) dan orderby nilai
> (descending)
> b. looping through all record lalu looping through group (kan group tadi
> udah di order) jd langsung aja isi kolom nourut 1,2,3,4 sejalan dengan
> looping group kalo kode group A ada 10 maka nourut sampe 10 dan kalo
> ketemu group baru mulai urut dari 1 lagi.
> 3. nah kalo kolom nourut utk masing2 group sdh terisi kan masing2 group
> pasti ada nourut 1-3
> 4. nah tinggal delete deh yg nourut > 3, jdnya yg tersisa kan semua
> group yg punya urut 1-3
>
> dari sini tbl-temp tinggal dipake deh utk create report/form, isi sudah
> top 3
>
> mungkin ada cara yg lebih mudah ?
>
>
> ----------------------------------------------------------
> This message contains confidential information and is intended only for the
> individual named. If you are not the named addressee you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately by e-mail if you have received this e-mail by mistake and delete
> this e-mail from your system. E-mail transmission cannot be guaranteed to be
> secure or error-free as information could be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The sender
> therefore does not accept liability for any errors or omissions in the
> contents of this message, which arise as a result of e-mail transmission. If
> verification is required please request a hard-copy version.
>
>
>