I'm using Access 2003 and have a form that allows the user to pick from a variety of filters, and I use VBA to update the recordset of a subform based on those filters (I generate a SQL statement in VBA). This subform can have duplicate client ids, and now I'm trying to get to a unique list of client ids.
Is there any easy way to query out the unique client ids using VBA if I have the source SQL for the subform? I've thought of these options:
SELECT DISTINCT client_id FROM <the recordset object>
, but I'm not finding any information that leads me to believe this is possibleSELECT DISTINCT client_id FROM ('original select query text here')
would work, but it gave me a syntax error in the FROM statementAim for the third alternative. This should work if you alias the subquery, and 'original select query text here'
can fit.
SELECT DISTINCT sub.client_id
FROM
(
'original select query text here'
) AS sub
If Access still chokes, show us what you have for 'original select query text here'
.
You're right about alternative #1 ... that is wasteful.
Alternative #2 is not possible because Access won't let you run a query using a recordset object as the FROM
source.