Results 1 to 3 of 3

Thread: How To Stop Duplication? [Newbie-ish]

  1. #1
    ^nighthawk^
    Guest

    How To Stop Duplication? [Newbie-ish]

    Ok the following code accesses a microsoft access 97 table.

    It gets all the items from the "Sport" field..and puts them into a list.

    The problem here is than i get duplicate entries.

    in the list

    Like Athletics
    Athletics
    Soccer
    Athletics

    one for each item.

    Is there a modification to th following code ican make to ignore duplicates.

    Code:
    Dim DB As Database
     Dim RS As Recordset
     
     'Use the OpenDatabase function to open our database
     Set DB = OpenDatabase("E:\Assignment3\Games.mdb")
     
     Set RS = DB.OpenRecordset("EventTable", dbOpenSnapshot)
     
     'Just in case
     frmSportList.cboSportList.Clear
     
     RS.MoveFirst
     If RS.EOF = False Then
            Do
                frmSportList.cboSportList.AddItem RS.Fields("Sport").Value
                RS.MoveNext
            Loop While Not RS.EOF
            RS.Close
            Set RS = Nothing
     Else
            RS.Close
            Set RS = Nothing
     End If
     DB.Close
     Set DB = Nothing
    Any help would be appreciated.

    Sample sQl statements and so on.

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Use :

    Code:
    Set RS = DB.OpenRecordset("select distinct(Sport) from EventTable", dbOpenSnapshot)

    Though I am not very familiar with DAO.

    But shd help.

  3. #3
    ^nighthawk^
    Guest

    Talking Ta!

    That wroked great thank very much

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