Set a field as variant in an equation
Forums
Hi,
I am trying to automate some analysis and I don't know how to fix the following code in order to include the field as variant because I have several fields in where I need to adjust the format. Can someone help me to insert the variable field in my equation editor? This is where my code stop working, I have copied it here! Thanks
Function ModifyAllDateField (DateField, WorkingDatabase) As Variant
Dim db As Object
Dim task As Object
Dim field As Object
Set db = Client.OpenDatabase(WorkingDatabase)
Set task = db.TableManagement
Set field = db.TableDef.NewField
'Users DateField variable passed to the function to set which field is checked
field.Name = DateField
' Checks if the field is already a date field, if it is, do nothing
' If the field is not a date field, then change it to a date field (saves processing time)
If field.IsDate Then
Set Task = Nothing
Set db = Nothing
Set field = Nothing
Else
field.Name = DateField & "_CORRECT"
field.Description = ""
field.Type = WI_VIRT_DATE
field.Equation = "@ctod(DateField, ""DD/MM/YYYY"")"
task.AppendField field
task.PerformTask
Set task = Nothing
Set db = Nothing
Set field = Nothing
End If
End Function
Hi Brian,
Hi Brian,
here is my option explicit and my sub main.
Let me know if this help.
Thanks,
Giorgia
Option Explicit
Dim VMFileName, EmployeeFileName, BillsFileName, BillsDetailsFileName, POFileName, PODetailsFileName, dbNetSuite, dbWorkday As String
Dim Result As Long
Sub Main
Client.ManagedProject = "LOC-0001 Procurement"
Call FileBrowser() 'Call GetFileNames()
Call VMImport() ' Import the VMF Input file
Call EmployeeInfoImport() ' Import the Employee Input file
Call BillsImport() ' Import the account #20000 transactions - main line
Call BillsDetailsImport() ' Import the account #20000 transactions - expense line file
Call POImport() ' Import the PO main line file
Call PODetailsImport() ' Import the PO details file
Call PassVMFields()
Call PassBillsFields()
Call PassBillsDetailsFields()
Call PRO_003_01()
Client.CloseAll
End Sub
Hello Brian,
Hello Brian,
Let's say the variable is of type String. And I want to write an equation that checks a string field
Dim code as String
Sub main()
code = "271"
...
...
equation = "BRA_CODE = " & code
...
...
End sub
The problem is that the equation variable reads it as :
"BRA_CODE = 271"
but I want it to read it as
"BRA_CODE = "271""
Please can you help?
Hi Oseroke,
Hi Oseroke,
You have to include the double quotes (") around the variable so your equation could be:
equation = "BRA_CODE = """ & code & """"
So when you have "" (two double quotes) IDEAScript will insert a single " instead of closing the string. So in this case the equation editor would see the equation as: equation = "BRA_CODE = "271"
You can also write it like this:
equation = "BRA_CODE = " & chr(34) & code & chr(34)
The chr(34) inserts a double quote.
Another option is to create a variable or constant to hold the double quote:
Const dblQuote = chr(34)
equation = "BRA_CODE = " & dblQuote & code & dblQuote
All of these should work assuming I didn't make a typo.
Brian
Hello i want to make my
Hello i want to make my equation works using variant:
My i get a help what is the correct syntax:
Function criterio
MsgBox ("TRANSFORMACION CARACTER")
MsgBox (sDate)
Set db = Client.OpenDatabase("A_DLPMT.IMD")
Set task = db.TableManagement
Set field = db.TableDef.NewField
field.Name = "MIN"
field.Description = ""
field.Type = WI_VIRT_NUM
field.Equation = "@If(FECHA_PAGAR<=sDate;@Age(FECHA_PAGAR;sDate);0)"
field.Decimals = 0
task.AppendField field
task.PerformTask
Set task = Nothing
Set db = Nothing
Set field = Nothing
MsgBox ("Fin Criterio")
End Function
Regards
Hi Giorgia and welcome to the
Hi Giorgia and welcome to the site.
I made some modification to your function. I added comments to the parts that I changed. So these are the following changes I made:
Hopefully this helps you out.
Thanks
Brian