Discussion Locked

Filter single column in a recordset

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I created a recordset in Visual Basic 6.0 consisting of 2 columns. How to clone this recordset so that the cloned recordset consists of a single column only having distinct record(s)?

eg: Original Recordset has 2 columns(fields) as:

Item WareHouseCode
---- -------------
CMT WHS1
CMT WHS2
PKG WHS1
PKG WHS2

The resultant recordset should give me only one colummn with distinct values. As in this case
Cloned Recordset:

Item
----
CMT
PKG

1 reply

by glen_mcleod

Why are you doing this on the client? This is something that you should let the server do. If you've executed an SQL statement to get the original recordset like this:

'Select Item, WhareHouseCode From yourTable'

then simply execute anotherto get your second desired recordset:

'Select Distinct Item From yourTable'

Recordsets do not have an easy way of doing what you want here, you'd have to code a nested loop structure manually. Which would be a big waste of time when the database can give it to you with 1 statement.

Glen

This discussion is closed to new replies.