My situation :
Question :When I load the table that contain field name "CLASS". it work Fine to me because only field name "CLASS" is exist in that shapfile
The problem come out when I load second table that contain both field field name "Kg_N" and "Kg_P" .I found that, the problem is because there are two field name is exist in table This might confusing the system becuase of this two field name is exist in table.
How to choose and select only one field name from the table if two field name are found exist in the table?
Code:Set vmr = New MapObjects2.ValueMapRenderer Dim fld As MapObjects2.Field Dim FoundFieldname As Boolean For Each fld In recs.Fields If fld.Name = "CLASS" Then FoundFieldname = True Dim j As Integer Dim strcStateName As New MapObjects2.Strings strcStateName.Unique = True Do Until recs.EOF strcStateName.Add recs.Fields("class").Value recs.MoveNext Loop vmr.Field = "class" vmr.ValueCount = strcStateName.Count For j = 0 To strcStateName.Count - 1 vmr.Value(j) = strcStateName(j) Next Set mlyr.Renderer = vmr 'Exit For ElseIf fld.Name = "Kg_N" Then FoundFieldname = True strcStateName.Unique = True Do Until recs.EOF strcStateName.Add recs.Fields("Kg_N").Value recs.MoveNext Loop vmr.Field = "Kg_N" vmr.ValueCount = strcStateName.Count For j = 0 To strcStateName.Count - 1 vmr.Value(j) = strcStateName(j) Next ' Set mlyr.Renderer = vmr 'Exit For 'Exit For ElseIf fld.Name = "Kg_P" Then FoundFieldname = True strcStateName.Unique = True Do Until recs.EOF strcStateName.Add recs.Fields("Kg_P").Value recs.MoveNext Loop vmr.Field = "Kg_P" vmr.ValueCount = strcStateName.Count For j = 0 To strcStateName.Count - 1 vmr.Value(j) = strcStateName(j) Next Set mlyr.Renderer = vmr 'Exit For End If Next fld If FoundFieldname = False Then 'MsgBox "no field name found" GoTo nofield: Exit Sub End If


Reply With Quote