Skip to main content

Search

Search

Variable Date Offsets using Radio Buttons

Comments

5 comments

  • Avatar
    Peter Thane

    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
  • Avatar
    Todd Ricker

    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
  • Avatar
    Peter Thane

    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
  • Avatar
    Todd Ricker

    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.

    1. Text Field set to Date (DateChosen)(Placed outside the label) > Linked to Date selector on my form page
    2. Text Field set to Number (DateOffset)(placed outside the label) > Linked to a radio button list
    3. 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
  • Avatar
    Peter Thane

    Glad you got there in the end

    0

Please sign in to leave a comment.