Change Layername in MapDisplay

Discussion created by bgisolution on Jun 14, 2011
Hi ESRI-Forum,

I want to create an automate mapprinting tool. I have a dropdown-list for selecting an attribut. after the selection I filter my layer "SELECTION" by SQL-Query via VBA.
Now only the polygons with the selected attribut would be displayed. All fine! Now I would change the name of the layer into the selected attribut, for example "SELECTION" to "Peters HotDogs". I could change the Layer-Name via VBA by following:

Set pMap = pMxDoc.FocusMap
Set pActiveView = pMap
pMapLayer(0).Name ="Peters HotDogs"

It changes the layername (Now I can find "Peters HotDogs" in the Layers), but not in the MapScreen. There always stand "SELECTION". What can I do?

I have try it again. When I use this code, ArcGis would refresh the Layout and write "Peters HotDog", only when I'm going in the property of the layer by menu. there stand the new name nad when I'm press okay, the new name would be shown in the mapdisplay.
How can I automate this? I use refresh for repaint the Map.

The solution was pMxDoc.UpdateContents!!!