set expiry date automatically based on input creation date S’abonner

0
Avatar
ameer ameer

Hi all,

 

I got create input name which is 'CreateDate' and user able to input/change the date in form display before proceed to do printing. but how can I create the expiry date based on CreateDate + 2 years? CreateDate format is ddMMyyyy and also can be WWYY,  and yyyyMMdd.

 

please advise/help.

 

thank you

10 commentaires

1
Avatar
Pete Thane
Actions pour les commentaires Permalien

If you are using either BarTender 2016 or 2019 then this process is fialry simple as you can use the Transforms>Offset option and then tick the Apply Offset after Data Entry option. For older versions this is more difficult as you would need to use a VB script routine to achieve this.

 

Are the three different date formats on the same label template? If so you will you will need to use a VB script routine to link them together as the sharing or just linking them via the Named Data Source option will not work in this instance.

Once you have selected the Data Type as Date for your label field you can then choose how you want the data to be displayed. There are various standard layouts in the list but if you cannot find the one you want then you can select Custom and then type the requirements in the pattern. As you can see the image below shows the WWyy you require.. If you search for Custom Date and Time Format Strings in the Help menu you will be able to see the various options that can be used for the custom option.

I hope this helps.

0
Avatar
Danny chuang
Actions pour les commentaires Permalien

  1.  This is how I work for it...hope to help you. I think there is a "Text Properties" which is link to "input" in template. Maybe use "Search andReplace" in the "Transform" of the Text Properties". I create an action list which is "yyWW" become to "yyyyMMdd".
  2. Certainly creating action list spend a lot of time. After you create 3 or more actions, export to XML file. Using Excel to open the XML file and it's easy to create more actions. Of course Import the XML file when you finished it. See the picture below. 
  3. As you ask how can I create the expiry date based on CreateDate + 2 years? CreateDate format is ddMMyyyy and also can be WWYY,  and yyyyMMdd. I think it's better to do in Excel file.

  

1
Avatar
Pete Thane
Actions pour les commentaires Permalien

From your other post Danny I see you are using v10.0. I certainly cant remember handling date formats changes the way use are proposing as I seem to recall there was a date option already that could deal with this. However as BarTender has no been available to purchase for around 7 years and came to the end of support in 2017 i no longer have access to this and so cannot confirm.

I do know the Offset in the Transforms option was not present in 10.0 and so what I suggested above would not be possible for you to implement. For that version I would have used a VB Event Controlled Post Prompt script routine to include a DateAdd 2 years option, so something like

Value = DateAdd("yyyy",2,Value)

 

0
Avatar
Danny chuang
Actions pour les commentaires Permalien

Thanks a lot. This is a topic that I am interested in. I am confronted different customers request different date format.

0
Avatar
ameer ameer
Actions pour les commentaires Permalien

Hi Pete Thane and Danny Chuang,

 

thanks for the advise. I will try out your suggestions. My workplace got version 10, 2016, and soon will purchase 2019.

 

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Hopefully this will explain the process.

1. Give the field that will contain the base/chosen date a name via the use of the Change Data Source Name button. To match the original post I have called it CreateDate.

 

2. For the offset date field set this to have a Date Data Type and choose an appropriate format as per the 2nd image in my post above.

3. Amend the Data Source to Visual Basic Script and choose the Event Controlled Script option and then then press the Edit.... button

4. In the column on the left choose the OnPostPrompt option and in the central box add the code shown on the screen below. Please note for the 1st line type the Value = and then double click on the name set in 1. from the right column to add the link to this field 

 

5. Click close and you are done.

 

 

0
Avatar
ameer ameer
Actions pour les commentaires Permalien

Hi Pete Thane,

I create "CreateDate" as shown above picture. Date is ddMMYYYY.

 

Then I create "ExpiryDate" with date format ddMMYYYY, but when I set the vb script and want to close it, got error as below;

 

Please advise.

 

Thank you.

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Not had a chance to look at this yet but,sometimes as the VB is trying to process a string of characters rather than proper data when you set up the config screen sometimes you get the Type Mismatch until actual data is available at the proper On....Event time.

If you add a ' at the front of the first line and then add a temporary new line 

Value = "26082020" 

does the mismatch error at the bottom disappear?

In which case the original code is probably okay anyway and if you try printing with the original commands it may work correctly.

I will try and look at this again tomorrow if I have time anyway.

Pete

 

 

0
Avatar
ameer ameer
Actions pour les commentaires Permalien

Hi Pete Thane,

 

 

Do you mean like above? still got the  error.

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

The problem is BarTender/VB is not recognising ddMMyyyy as a date format and so cannot perform the DateAdd command. If you amend CreateDate so it is set to dd/MM/yyyy format and then drag it off the label so it doesn't print but can still be referenced you can then add a 2nd VB item but remove the DateAdd line. For both the VB fields set the Type to Date and use Custom ddMMYYYY. 

Vous devez vous connecter pour laisser un commentaire.