Results 1 to 3 of 3

Thread: COMBO BOX

  1. #1

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621

    Unhappy

    Dear All

    I have a combo box on a form that is populated by fields from a recordset. There are some duplicate values in the recordset but I only want to display one instance of it in the combo box.

    I have got round by the example in the code but was wondering if anyone knows another way maybe easier\quicker.

    Code:
    Dim sLastItem As String
    
        Do Until rstTemp.EOF
            If Not sLastItem = rstTemp![Result] Then
                 combo1.AddItem rstTemp![Result]
                 sLastItem = rstTemp![Result]
                 rstTemp.MoveNext
            Else
                 rstTemp.MoveNext
            End If
        Loop
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    You need to use the DISTINCT SQL command;

    eg;

    SELECT DISTINCT name FROM authors

    will only return one of each name... (assuming that some names are the same in the table)

    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    Thanks Buzby

    That works a lot better
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width