Sum date with excel field
I am new in vbscript.
I have a field in my label type date: 01/07/2017
I have an other field in excel for example: 15
I need sum the field 01/07/2017 plus field excel 15
So, the result field newdate shoud be: 01/22/2017
How, i can make it? sameone help me?
You probably need to set is as an Event Controlled Script and OnNewRecord so it picks up the value to add on to the date when a new database record is loaded.
- For ease I would give the date field a name (from the Change Data Source Name button in the Properties of the field)
- In the VB Script Editor you need to use the DateAdd command and so would need something like
Value = DateAdd(("d", database field, date text field)
with the two fields being added by double clicking on their respective details in the Script Assitant column on the right hand side0
Hi Peter, tanks to your answer.
I try to make the way that you recommended, but not work. I really do not so good in VBScript.
Is possibe you help me, with it?
If yes, atacched screens , that show label design, the fileds, database and the script command.
The Bartender show-me an error message relationed with the script command, however,
i am not have knowledge de Vb script.
Tanks a lot. Bye.0
It is hard to tell from the screenshots but I think you have the VB being processed at the wrong time.
Make sure the Type of VB Script is set to an Event Controlled Script and add the code in the OnNewRecord option as per the bottom screen shot below.
I have tweaked the VB a bit and added in a Value1 = and Value2 = and to get the value of these to be linked click on appropriate fields in the right hand column.
If you are not sure how to set a name for a data source, then the top screenshot may help - click on the button where the mouse pointer is hovering over....0
Hi Peter, tanks by response. Work perfect !
Now, i am with other doubt and need your help if possible.
In other case, i need sum the number that get a value of checkbox.
how changes i have make on vbscript, because the number of days, the source data is the value of check box.
See atacched screens: Tank You Again!0
You need to do something similar to the above but use Event Controlled > PostPrompt option.
Here is one way to do it
- Add on to the side of the label template (so they wont print) a normal text field (I gave mine a value of 1) and a date field.
- Make these two named data sources, I called them OffsetOrCustom and CheckField
- Make the Manufacture Date field a named field (I use ManuDate)
- On the Data Entry Form (Form 1) add a Date Picker field that is linked tot he ManuDate field
- Add a Radio Button list with the values 2, 4 and X and add a suitable description - see screenshot below
- Add a new Data Entry Form (Form 2) and add a new DatePicker field and link this to the CheckField
- Right click on the name Form 2 at the bottom of the screen and go into the properties of the Form. Highlight the name Form 2 in the column on the left and then use the button to the right of the Show When box to change it Conditionally Based on Expression and change the variable to OffestOrCustom equals X
- Click on Template 1 to return to the label itself and then go into the Properties of your Expiry Date field and with the Data Type set as Date (in the correct format you want) change the Source to VB Script and Event Controlled Script and press the edit button.
- In the AutoSelected event I change the setting to Value = () to give a default of today's date as the base.
- In the right hand column scroll down and select OnPostPrompt and in the box you need to end with something like this
Value = Format.NamedSubStrings("OffsetOrCustom").Value
If Value = "X" Then
Value = Format.NamedSubStrings("CheckField").Value
Else Value = DateAdd("yyyy",Format.NamedSubStrings("OffsetOrCustom").Value,Format.NamedSubStrings("ManuDate").Value)
Value = Value
I hope this makes sense
Pete, tanks for your help, it is work fine, you are the man.!!
A last doubt, the field Expire Years (custom date to be used) it can not be previous field manudate.
Is it possible block this field, to user, not choice a date previous to field manudate ?
Tanks one more time, i wait your response..0
Yes this can be achieved.
Go into the Properties of the custom date field got to Transforms>Range Checking and configure the "Get first valid date from named data source" to the ManuDate field0