Dialog Box to rename a field

5 posts / 0 new
Last post
ElaP
Offline
Joined: 03/30/2022 - 04:21
Dialog Box to rename a field

Hi everyone,
I hope you are doing great. I would like to ask for a help.
I need a script to update a historical information and for that I renamed a column using a dialog box, but it is not working.

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

I think you are missing some quotes:

field.Name = """" & Dat & """"

There should be four quotes on each side.  The two in the middle give you the single quote in the string.  The two outer quotes are opening and closing the string.  Right now the equation editor is seeing:

"DAT" and it doesn't know what to do with it.  With the change it will instead see what is included in the Dat variable.

ElaP
Offline
Joined: 03/30/2022 - 04:21

Hi Brian
Thanks for your reply, but now I have a new error 
(task.ReplaceField "SCORE", field) "The default field name is invalid. Field names may only contain letters, numbers and underscores and must begin with a letter."
I didn`t understand this error.  Both variables name, the initial and the new one, has only letters and numbers, and begins with letter.
Thanks a lot
 

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

Sorry, my fault.  I was thinking that the field.Name was an equation when it wasn't.  So I was giving you advice if this had been an equation.

What you need to do is just make it equal to the variable so:

field.Name = Dat

And that should do it.

ElaP
Offline
Joined: 03/30/2022 - 04:21

Hi Brian
Perfect, thanks a lot!