Format.cancelprinting S’abonner

0
Avatar
Legacy Poster

Hi Guys,

 

For preventing a label to be printed when a date difference is more than 6 months I use the format.cancelprinting function, after using this function I have to click the OK button 9 times, what's wrong in my script? I allready used different kinds of scripting all with the same result.

 

Example:

 

a=Format.NamedSubStrings("Datum").Value 
b=Date
c= DateDiff("m", a, b )
 
Value=c
 
if c=>6 then
Format.CancelPrinting("Older than 6 months, continue?")
Else 
 
End if
 
Bartender 10.1 SR2 is used.
Hope you can help me out.
 
Thanks and regards.

9 commentaires

0
Avatar
Fernando Ramos Miracle
Modérateur
Actions pour les commentaires Permalien

Hello Peter,

 

1. Could you let me know on what type of VB Script you've entered the code (document level, data source or "OnProcessData" from the "Transforms" tab).

 

2. If using an event based VB script, on what event are you entering your code?

 

3. Could you attach a simplified version of your document so I can test your script?

 

Regards.

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Thanks for your answer, the label is attached.

 

Regards,

 

Peter

0
Avatar
Fernando Ramos Miracle
Modérateur
Actions pour les commentaires Permalien

Hello Peter,

 

I'm afraid I haven't been able to reproduce your issue, and I can't see anything wrong with your code.

 

Could you let me know exactly where are you printing from? Are you working with BarTender directly, or are you maybe using Print Station?

 

As a possible solution, you might want to try changing your VB Script to an "Event Based VB Script" and add your code to only one event (maybe "OnPrintStart"). This way you can make sure the code will run only once.

 

Regards.

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Hi Fernando,

 

Putting the script in the "Event based VB script" (OnPrintStart) works, however when I change the date field to a supplied input field (date picker) an error comes up (attached)

Hope you can help me out.

 

Thanks!

 

Peter

 

0
Avatar
Fernando Ramos Miracle
Modérateur
Actions pour les commentaires Permalien

Hello Peter,

 

Could you attach the latest version of your document so I can try reproducing your error message?

 

Thanks!

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Hi Fernando,,

 

Here's the label, date field works, when changing to supplied input the former script error appears.

 

Thanks!

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Hi Fernando,

 

Did you had a chance to take a look at the attached label with the date selector?

 

Thanks!

0
Avatar
Fernando Ramos Miracle
Modérateur
Actions pour les commentaires Permalien

Hello Peter,

 

Sorry for the delay.

 

I've been taking a closer look to your issue and it certainly looks like an issue with our software. The problem is not about a type mismatch (although that's the symptom) but that when assigning a variable with the value of a named data source on the OnPrintStart event the variable stays empty. I've already reported it to our development department so we'll hopefully solve it soon.

 

In the mean time, and for your script to work, try pasting the script (as it is) in a different event; such as OnPostPrompt or OnPrePrompt events if you wish the cancel after or before the actual prompt respectively.

 

*Tried them both with your document and they certainly work.

 

Regards.

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Hi Fernando,

 

Thanks! OnPrePrompt was the right event, working perfectly now, case closed  :)

 

Regards.

Vous devez vous connecter pour laisser un commentaire.