Preventing Certain Records Being Printed
Hello all,
I was just wondering if there was a way to query a database and not have bartender print a label if a certain criteria wasn't met.
For instance, we use bartender to pull from a database via our part number, this then pulls back description etc etc from the record.
Now if this part has a field called 'history' for instance (as in number of parts sold to date) and it's value was 0, is it possible for bartender to be controlled to display a message box with along the lines of 'Are you sure you want to print this label as we dont sell any' kind of thing?
Does this make sense?
Regards
Ryan
-
Michael Toupin (mtoupin
★ BarTender Hero ★
The easiest way to do this would be with a VB script. You'll want to put something like
If History = 0 then
value = format.cancelprinting("Are you sure you want to print this?")
This would result in a popup with the request whether or not to continue printing.
0 -
Legacy Poster
★ BarTender Hero ★
Many thanks for your reply Mike,
Whereabouts would i add the VBScript for it to prompt? In the query?
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
Hello again,
I've tried various different places of adding vb but still not getting the results i'm after.
Should i move this to the scripting forum? Or is there another way to solve my problem?
Regards
Ryan
0 -
Fernando Ramos Miracle
★ BarTender Hero ★
Hello Ryan,
You could create a new object with a Vb script type data source and use an event based script. The code would need to be added to the "OnNewRecord" event so it acts when the new record of your database is selected.
Another option would be to use a document level script (from the "File>BarTender document options..." dialog, under the VB Scripting tab), using the same event.
*Please note that you'll need to reference correctly your database field and close the "If...Then" statement.
If Field("Table.History") = "0" Then
Value=format.cancelprinting("Are you sure you want to print this?")
End If
Regards
0 -
Legacy Poster
★ BarTender Hero ★
Excellent stuff,
Thank you both very much, i have it sorted now.
For those in the same position, i used the document level script as suggested by Fernando and used the following in the 'OnNewRecord' script
ReferenceField("YourTable.YourField")
If Field("YourTable.YourField")= "0" Then
Value=format.cancelprinting("Are you sure you want to print this?")
End If
0 -
Legacy Poster
★ BarTender Hero ★
Further development.............This doesnt seem to work in Print Station, even though the label through Bar Tender works as it should.
Any ideas?
Regards
Ryan
0 -
Fernando Ramos Miracle
★ BarTender Hero ★
Hello Ryan,
I've been doing some tests and I can certainly make it work as expected in Print Station.
1. Could you let me know what version of BarTender are you working with?
2. Make sure you are working with the latest release available for your BarTender version. You'll find the download link for the latter on the below webpage (you'll need to select your version):
http://www.bartenderbarcodesoftware.com/label-software/service-releases.aspx
3. As you are working with a document level script, please avoid using the "Value=" part of the code (there's no object actually taking that value). Instead try the below code:
ReferenceField("YourTable.YourField")If Field("YourTable.YourField")= "0" ThenFormat.cancelprinting("Are you sure you want to print this?")End If0 -
Legacy Poster
★ BarTender Hero ★
We are using Bar Tender Automation 10.1 SR2
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
For some reason, your 3rd option didn't show up on my screen when i looked.
Removing the value= part seems to have done the trick B)
Thanks again
Regards
Ryan
0 -
Legacy Poster
★ BarTender Hero ★
.............sorry i'm back
For some reason it will not work on the very first time the lookup is performed. I know the script is in the 'OnNewRecord' event but it will only seem to work after the first lookup has been processed.
To replicate the error, close down print station, then open up. The first time you search it will go through as if the value doesn't equal 0, then if you run the same search again, the code will kick in and show the message box
Any thoughts?
Regards
Ryan
0 -
Fernando Ramos Miracle
★ BarTender Hero ★
That is strange and definitively shouldn't happen. Could you attach the latest version of your document so I can take a look at it?
Could you also let me know what version, edition and build of BarTender are you working with? Make sure you've got installed the latest release for your BarTender version:
http://www.bartenderbarcodesoftware.com/label-software/service-releases.aspx
Regards
0 -
Legacy Poster
★ BarTender Hero ★
Hello,
We are using BarTender Automation Edition 10.1 SR2 which i think is the latest release?
I'm not too keen on attaching the document due to the sensitivity of the information, it's also llnked to a database that exists on our internal server so would it still be useable?
Regards
Ryan
0 -
Fernando Ramos Miracle
★ BarTender Hero ★
Indeed that is the latest release at the moment.
Could you instead build a simple test document implementing the code and try to reproduce your issue? You could then attach this sample so I can see exactly what might be going on.
Regards.
0 -
Legacy Poster
★ BarTender Hero ★
Ok will do
Many thanks
Ryan
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
14 commentaires