# Rename attrib table field

**URL:** <https://mapwindow.discourse.group/t/rename-attrib-table-field/1643>\
**Category:** MapWinGIS\
**Created:** [October 2, 2023, 11:04pm UTC](https://mapwindow.discourse.group/t/rename-attrib-table-field/1643 "2023-10-02T23:04:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pan054](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@pan054](https://mapwindow.discourse.group/u/pan054)\
**Post date:** [October 2, 2023, 11:04pm UTC](https://mapwindow.discourse.group/t/rename-attrib-table-field/1643/1 "2023-10-02T23:04:30Z")

</div>

I’m trying to rename an attribute table field (see code snippet below, Sf is a shapefile object).

```auto
        'Renames a field in the shapefile's attribute table
        Dim FldIdx As Integer
        If Sf Is Nothing Then Return False
        FldIdx = Sf.FieldIndexByName(CurrentFldName)
        If FldIdx < 0 Then Return False
        Sf.StartEditingTable()
        Dim Fld As MapWinGIS.Field = Sf.Table.Field(FldIdx)
        Fld.Name = NewFldName
        ' check the change
        FldIdx = Sf.FieldIndexByName(NewFldName)
        Sf.StopEditingTable()
        Dim Ok As Boolean = Sf.SaveAs(FullFileName)
        ErrMsg2 = Sf.ErrorMsg(Sf.LastErrorCode)

```

All goes well, but it will not save the shapefile (no errors though).  
I can’t find anything wrong with the shapefile.  
As a workaround I could add a new field, copy the contents of the old one and delete the old field, but I’m trying to keep it simple.  
Any suggestions would be welcome?  
Cheers  
Francis
