Categories not generating

Hi Jerry

MapWinGIS version 5.2.4 64 bit Windows 10, MS Access 365 VBA

Whats my problem?

  • I am trying to generate categories, but they don’t appear on the map.

What I am trying to do?

  • create a map of roads that are classified by proposed maintenance treatments.

  • Load the 5 treatment categories into the map, and set colors for each treatment

  • I use the following code to do this:

                         sf_Lines.Categories.ClassificationField = 4
                         
                    With sf_Lines.Categories.Add(Treatment)
                          .ValueType = cvExpression
                          .Expression = "[TREATMENT] =" & Treatment
                          .DrawingOptions.Visible = True
                          .DrawingOptions.LineColor = RGB(T_Red, T_Green, T_blue)
                          .DrawingOptions.LineWidth = 5
                   End With
    

and after all treatments are loaded, run

 sf_Lines.Categories.ApplyExpressions

I believe the code is working. I exported the Category settings to XML and it appears all my settings are there.

 Map0.SaveLayerOptions(0, "Line_Samples.txt", True, "")

image

Thanks
Stu

Hello Stu.

If the Treatment value is a string, you need to put it in quotes, something like

.Expression = "[TREATMENT] = """ & Treatment & """"

See if that does it…

Regards,
Jerry.

Jerry

It works beautifully!

Thank you very much

Stu