General discussion

  • Creator
    Topic
  • #2310978

    Filter single column in a recordset

    Locked

    by icekoool ·

    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

All Comments

  • Author
    Replies
    • #3469852

      Filter single column in a recordset

      by glen_mcleod ·

      In reply to Filter single column in a recordset

      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

Viewing 0 reply threads