Results 1 to 4 of 4

Thread: Deduping in VBA using an ID field???

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2012
    Location
    Here
    Posts
    18

    Deduping in VBA using an ID field???

    This is what i have so far:

    Code:
    CntTblSQL = "SELECT sorted.LOC_ID, Count(sorted.LOC_ID) AS CountOfLOC_ID INTO CntTable FROM sorted GROUP BY sorted.LOC_ID ORDER BY sorted.LOC_ID;"
    
    DoCmd.SetWarnings False
    DoCmd.RunSQL CntTblSQL
    DoCmd.SetWarnings True
        
    pass1 = "SELECT * FROM CntTable"
    dataconnect.Open pass1, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    
    With dataconnect
    Do While Not dataconnect.EOF
    
    strLocId = dataconnect.Fields("LOC_ID").Value
    Count = dataconnect.Fields("CountofLOC_ID").Value
    
    MsgBox strLocId
    MsgBox Count
    .MoveNext
    Loop
    
    End With
    dataconnect.Close
    End Sub
    I have no idea which way to go next, basically i have a field called "LOC_ID" that has a bunch of duplicates in it. I need to select one of each variation using the "LOC_ID" field while still keeping all the other fields in the record.
    any help would be much appreciated!
    Last edited by Siddharth Rout; Jul 23rd, 2012 at 04:32 PM. Reason: Added Code Tags

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