DISTINCT values of a Subform Recordset (1 Viewer)

jharding08

Member
Local time
Today, 09:58
Joined
Feb 16, 2021
Messages
55
Is it possible to take a RecordsetClone of a subform(filtered) and then in VBA, query on the distinct values of that recordset?

--------------------------------------------------------------------------------------

Set rs_Clone =Me.subfrm.Form.RecordsetClone

/**Set another recordset (rs_Cust) to Get Distinct CustID from rs_Clone**/

Do until rs_Cust.EOF
Do Stuff
Loop

------------------------------------------------------------------------------------------

I dont want to use the recordsource and filter of the subform, just the resulting recordset after filtering
 

bastanu

AWF VIP
Local time
Today, 09:58
Joined
Apr 13, 2010
Messages
1,401
Not aware of a way to do that other than using the original record source and applying the current filter, but you can use a structure similar to this to skip unwanted records, which would kinda' give you want you need:
Code:
Dim lCustID as Long

'assumes rs_Clone is sorted by CustID
Do until rs_Clone.EOF
    If rs_Clone("CustID")=lCustID Then GoTo NextCloneRecord 'skip if same ID   
    Do Stuff
NextCloneRecord:
lCustID = rs_Clone("CustID")
rs_Clone.MoveNext
Loop
 

Users who are viewing this thread

Top Bottom