Variable Date Offsets using Radio Buttons
Hello Everyone,
I have a label that I am working on in which I have to display a Calibration due Date. Depending on the product status, the offset for calibration due is different.
Option Offset Value
1 12
2 14
3 15
Expected output: Date entered + Offset Value in Months (based on choice made)
Here is what I have so far.
TEMPLATE PAGE
I have placed a text object for the calibration date
-Data Source: clock
-Data type: (Date)
-Transforms:
---Offset: Named Data Source: +[Offset] Month(s)
---Prefix: Calibration Due Date:
A Named Data Set has been created (Named: Offset]
I have placed a text object for the calibration date
-Data Source: Embedded Data
-Data type: Number
-Transforms: None
FORM PAGE
Date form using the Due Date pulled from the Object Data Sources
Radio Button list, with 3 options. Values set to 12, 14, 15. Linked Data Source is set to Offset.
When I go to run the label, and select one of the radio buttons, the date does not change. If I change the value in the Linked Data Source, the date changes as expected. Somewhere along the way my Radio button list is not updating the values of the Linked Data Source. I have also tried this using a dropdown list with no luck. Obviously I am missing a step somewhere in there. Any ideas?
Using BarTender Designer 2016 Professional and used this thread for my initial reference for this project.
Thanks in advance.
-
Hi Todd,
Not tried to replicate this yet but I think this is to do with the order that the fields are processed on the label and you may need handle this in a different way.
What you may have to do is use VB script to perform the offset for you.
1. Make your calibration date field a VB Event Controlled Field, but leave the type as Date and the format you want.
2. Adjust this field to use the Post Prompt option and use the Date Add command to give you something like
Value = Now()
Value = DateAdd("m",<Offset>,Value)
NOTE: for the <Offset> string double click on the name of the string in the shared substring list in the right hand column to add the proper command in.
Pete
0 -
Hey Pete,
Thanks for the quick response. Unfortunately this did not work. One of the problems I saw was when populating the values in the script you gave me above is that when I go to chose from my template objects in the script assistant. Radio Button List or drop down list doesn't have the option to choose values even though I have placed values in there
If I could get the values my script would look like
Value = DateAdd("m",[Format.Objects("Radio Button List 1").Value],Date)
or I could try using the following in the Named Data Source, and use the standard Offset by calling the NDS.
Value = Format.Objects("Radio Button List 1").Value
Also tried making a new template, just see if I could get this to work without all the objects and forms on the template just to see if something else was causing the problem. But unfortunately, that did not work as well
0 -
You need to link the field that has the chosen offset in it rather than the Radio object itself. If the field doesn't need to be printed you can set it to not appear on the label (Print When set to Never in the options for the text object name in the Properties of the field), or else just drag it off the label to the side as the VB will still work.
I can't add on a sample BTW file on but below is a screenshot of the VB screen as well as a print preview showing the 15 month offset option in use from the chosen date of the 9th July.
This label contains 3 fields
- A date field linked to a Date Picker (DateChosen)
- A text field linked to a 3 choice Radio Button (OffsetMonths)
- And a VB Event Controlled Post Prompt DateAdd field that adds OffsetMonths to DateChosen and displays in a Date Format (as chosen from Data Type > Date options for the field)
Pete
1 -
Pete,
Thanks again. Ended up getting a mismatch when I tested the script. I verified I didn't have any typos or extra characters. I am suspecting somewhere along the way I am just linking things up differently than you are which caused the mismatch.
Regardless, your suggestion led me down to try slightly different approach (which I will place below for anyone else who runs into the same problem) which ended up resulting in success.
I went with creating your 3 objects on the template screen.
- Text Field set to Date (DateChosen)(Placed outside the label) > Linked to Date selector on my form page
- Text Field set to Number (DateOffset)(placed outside the label) > Linked to a radio button list
- Text Field set to Date and linked to Named Data Source (Date) | Transform Offset to Named Data Source +[Offset] Month(s), Apply after data entry. (Calibration Date)
Also created 2 Named Data Sources
1: Event Control Script (Date) | OnPostPrompt
Value = Format.Objects("DateChosen").Value
2: Event Control Script (Offset) | OnPostPrompt (I probably could have just put this into my text field (Calibration Date).
Value = Format.Objects("DateOffset").Value
This method probably added one extra step in the process from yours. But the end result is it worked. I would still like to see yours working, so I plan on playing with it a little more during my downtime.
Thanks again.
1 -
Glad you got there in the end
0
Please sign in to leave a comment.
Comments
5 comments