Unprotect a column

2 posts / 0 new
Last post
Jiyajijp
Offline
Joined: 12/08/2016 - 06:34
Unprotect a column

Hi Brain,
I have extracted a single record to from source file to extracted File.
Then I need to edit the values in this column. Is it possible.
I tried to enable protect = False, but it's not working. I tried with the below code. could you please check this.
Dim db As Database
Dim table As Object
Dim newFieldObject As Object
Dim newFieldName As String
Dim newField As Object
 
Set db = Client.OpenDatabase(dbName)
    Set newField = db.TableManagement
    Set table = db.TableDef
    Set newFieldObject = table.newField
    Set newFieldName = "Colname"
    newFieldObject.Name = newFieldName
    newFieldObject.Protected = False
    newField.PerformTask

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Jiyajijp,

A couple of things with this.  It doesn't work on a virtual field but only an IDEA field.  Also what you are doing above is creating a new field for a new database, if the field already exists you can do something like this:

Set db = Client.OpenDatabase(dbName)

Set table = db.TableDef

Set field = table.GetField("MY_FIELD")

field.Protected = True

this will unprotect a field for editing.  Once you are done then you can protect the field with:

field.Protected = True

Hope that makes sense.

Brian