Avatar of Mark1110
Mark1110

asked on 

Duplicate Records In A Shape Command

I inherited a VB6 applications that uses the SHAPE command. I have never used this command before. I am getting duplicated records and I can't figure out how to get rid of them. Here is the code:

strSQL = "SHAPE {SELECT distinct mbs " & _
         ", dummy1 as currprem1 " & _
         ", dummy1 as underrequiredpercent1 " & _
         "FROM client where " & strWhere & " order by mbs }"

strSQL = strSQL & " APPEND ((" & _
         "SHAPE {SELECT distinct mbs,caseno,casename, TermDate, AppealRateChange " & _
                       ", dummy1 as currprem2 " & _
                       ", dummy1 as requiredprem2 " & _
                       ", dummy1 as soldprem2 " & _
                       ", dummy1 as premdiff2 " & _
                       "FROM client where " & strWhere & " order by  casename }  " & _
         " APPEND ({SELECT distinct * " & _
                       ", dummy1 as currprem3 " & _
                       ", dummy1 as formula3 " & _
                       ", dummy1 as requiredprem3 " & _
                       ", dummy2 as ftype " & _
                       ", dummy2 as fabbrev " & _
                       ", dummy2 as pabbrev " & _
                       ", dummy2 as uwname2 " & _
                     " FROM client where " & strWhere & " }" & _
            "RELATE caseno TO caseno) " & "As ChapterDetaillines"

 strSQL = strSQL & ") " & "RELATE mbs TO mbs)" & "AS ChapterCasename"

rst.Open strSQL, cnn2, adOpenKeyset, adLockBatchOptimistic

While Not rst.EOF
     rs2 = rst("ChapterCasename")
     While Not rs2.EOF
        rs3 = rs2("ChapterDetaillines")
        While Not rs3.EOF


I used distinct in a couple of places with no luck eliminating the duplicate records. I was thinking of putting the result set in a temporary table or cursor then I am not sure how to handle the recordsets. Can someone help me.


Mark
Visual Basic Classic

Avatar of undefined
Last Comment
ema20

8/22/2022 - Mon