DISTINCT values of a Subform Recordset (1 Viewer)

jharding08

Member
Local time
Yesterday, 21:52
Joined
Feb 16, 2021
Messages
52
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
Yesterday, 21:52
Joined
Apr 13, 2010
Messages
1,173
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