Hi rafe/Gord
Quite a bit of heavy coding rafe-I'd need the aspirins now!
But I did pull out a few more of my hair and finally got to a very compact code solution.
Drawing upon the various ideas put up here, I found the flagging proposal very neat and have used it here.
This is how it's done.
I modify my original table (dalloc_all) to add a yes/no field called 'selected'.
I make a form with a button named 'exp2exl'
on click of the button add this code
-------------
Sub exp2exl_Click ()
Dim mydb As Database, mytable As Recordset
Dim cmonth, pmonth As Variant
Dim i,tc As Integer
Set mydb = DBengine.Workspaces(0).databases(0)
Set mytable = mydb.OpenRecordset("select * from dalloc_all where [mwrot]>0 order by [month],[mwrot]desc"

'[mwrot] is the field contaning the productions
tc = 0 'set top3 counter to 0
pmonth = "" 'set variable previous month
mytable.MoveFirst
Do Until mytable.EOF
cmonth = mytable!month 'get value of current month
If (cmonth = pmonth) Then 'see if current and previous
'month are same
If tc < 3 Then 'increment top3 counter if <3
tc = tc + 1
mytable.Edit
mytable!selected = -1 'set selected field to yes
mytable.Update
End If
ElseIf (cmonth <> pmonth) Then 'if current and previous
' month <>
tc = 1 'a new month group
'so set top 3 counter to 1
mytable.Edit
mytable!selected = -1 'update selected to yes.
mytable.Update
End If
pmonth = mytable!month 'get current month into
'previous month variable
mytable.MoveNext
Loop
MsgBox "done" ' DONE DONE !!!!
mytable.Close
End Sub
-------------------
This works fine and fantastically fast.
From here it's simple, put in a docmd to get out the records set to 'yes'
Now I want your comments on this, Im not very sure about all the implications of the code and may have missed something.
On my records it's working fine and should serve as a generalised solution to finding the
TOP values in GROUPED data.
waiting for your expert comments
regards
Tigi