Append Field from my variable

4 posts / 0 new
Last post
lucas79
Offline
Joined: 05/24/2019 - 12:50
Append Field from my variable

Hello, how are you? 
I need help, I have a variable as a string and I can't insert the value of the variable into the new column. Is it possible to do this?
For example: 
Dim instancia As String
Set db = Client.OpenDatabase("Parámetros de contraseña.IMD")
Set task = db.TableManagement
Set field = db.TableDef.NewField
field.Name = "INSTANCIA"
field.Description = ""
field.Type = WI_VIRT_CHAR
field.Equation = instancia 'my error is here, I don't know how to add the content of my variable as a value of the fields.
field.Length = 100
task.AppendField field
task.PerformTask
Set task = Nothing
Set db = Nothing
Set field = Nothing
 
trim the code to where I understand that I have my error.
I await your reply.
Thank you so much!

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

Sure you can do the following:

field.Equation = chr(34) & instancia & chr(34)

The chr(34) adds quotes around whatever the value contains within the instancia variable.

lucas79
Offline
Joined: 05/24/2019 - 12:50

Thank you so much!
You are the best.

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

Glad I could help.