I am building a report and would like to have a barcode displayed in the detail band if there is data in a particular field and not display anything if the field is empty. I have tried various code found in search on this forum but so far have not been able to get anything to work properly.
For more detailed explanation:
Printing label that has:
Unit Name (barCode1)
Serial Number (barCode2)
Internal Code (barCode3)
I want the label to print Unit Name and Serial Number every time, and if there is data in Internal Code (barCode3) to print it otherwise hide it. By default the barcode, if there is no data, prints something that won’t scan.
Hi
I would suggest a Before Print script of the Detail band that checks to see if the datafield is empty or not, and if it is, sets the barcode field to not be visible.
For example, if thebarcode field for this Internal Code field is the Text1 field (LT_Unit_Label_Text1) and the name of the barcode field is barCode3 - I would have the Detail band’s Before Print script such as:
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
string InternalCode = Convert.ToString(GetCurrentColumnValue(“LT_Unit_Label_Text1”));
if (InternalCode == “”)
{
barCode3.Visible = false;
}
else
barCode3.Visible = true;
}
I would be happy to create a custom script for you. Do provide that identified in the topic Custom-report-templates so that I can provide a quote - i.e. send to support@ayanova.com a mock up of what you want, what grid the report from, what fields, etc.
Thank you that did it. I was mainly trying to put the script in the actual Field properties BeforePrint.
Has something changed in the new version (6.3.0.0), because I could have swore I had this working fine previously, and now with the new version of Ayanova that code seems to be suppressing all barcodes.
Hi
I am not aware of any issues.
First find a copy of the report that was previously printed out with a barcode, and make sure you are testing the print preview on the exact same unit and that this unit has the exact same data entered in the fields that were when you printed out.
You never did say in your previous posts what the exact fields were - I made an example referring to Text1, but you did not say.
Do open the report template in the report designer, and make a copy of it (so not changing the original).
And make sure there are no errors on the design panel, or when you print preview.
Also hard for me to say without actually seeing a copy of the report template - do export and attach. Be also sure to specify what fields precisely are being referenced in the unit, and make a screenshot of the unit entry screen of one that won’t supproess so that I could recreate here.
Attached please find the report
Also, I’m not sure if this has an impact on it, but I’m printing off multiple labels… not one… and out of those multiple labels, some will have data in the field and some will not. Not sure if the script as it exists above is an “all or nothing” where if one or the first check fails, it fails all the subsequent labels.
Please make a screenshot of the unit entry screen or provide what is in what speific fields so that I can see what exactly you have in the relevant fields so that I can recreate here and use. Otheriwise what I enter for serial etc may not be what you are using, and therefore would not be able to get the same results as you. Do post right away so that I can do this.
Please find attached two images, one of the unit entry screen and one of the labels when I remove the Onprint script.
The big blocky barcodes are what show by default when the field is blank, which is what I would like to eliminate.
Hello
Your script would not have worked in a previous version either.
All of your fields were in the detail band for the WorkorderHeader itself, instead of a detail band for the WorkorderHeaderWorkorderItem. And nothing was being returned for string InternalCode = Convert.ToString(GetCurrentColumnValue(“LT_Unit_Label_Text1”)); so therefore every instance would always be false and nothing would show.
The Unit is from the dataset WorkorderHeaderWorkorderItem, so to be able to actually GetCurrentColumnValue of LT_Unit_Label_Text1, you need to be in the detail band where the report designer can access this - in a detail band that is bound to WorkorderHeaderWorkorderItem.
.
I have attached an edit of the report template. Note that I have done the following:
- added the WorkorderHeaderWorkorderItem bound detail band
- moved all of your existing fields down into that band
- removed the script from the detailBand1
- added the script to the Detail band
- and in the script, specifically called the band DetailReport that is bound to the WorkorderHeaderWorkorderItem
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
string InternalCode = Convert.ToString(DetailReport.GetCurrentColumnValue(“LT_Unit_Label_Text1”));
if (InternalCode == “”)
{
barCode3.Visible = false;
}
else
{
barCode3.Visible = true;
}
}
Please note that this is considered script customization, and normally would have required payment.
Thank you so much for the assistance!! Is there an in depth manual on the report creator? What I saw was only basic information and not much regarding specific information, such as scripting syntax, band descriptions and interaction, etc.
sasserian (5/19/2010)Thank you so much for the assistance!! Is there an in depth manual on the report creator? What I saw was only basic information and not much regarding specific information, such as scripting syntax, band descriptions and interaction, etc.
The Help documentation and the examples in this forum are provided to help those that wish to do the basics including overview of scripts, band use, etc. But step by step manual documentation is not possible for all of the possibilities.C# used for scripting is a huge discipline and there are literally thousands of books about it. It is suggested if you wish to create your own scripts to check out existing samples in existing sample report templates in AyaNova and on the forum, and then search online for syntax etc. You will have to test and try, but there is not a single manual for this. As offered, we can provide report customization over what is provided as examples here on the forum and in the Help documentation for you for a fee - see topic Custom-report-templates