Crystal Reports: Shared variable resets after page instead of group


This is for Crystal Reports 2013 Support Pack 1

I have a Shared Variable that's giving me fits. In particular, it works while my report is only one page long, but it resets itself if the report is more than a page long and I don't know why. The end result is that it displays only the data for the page it is on, not the data for the grouping it lives in, which is the intended behavior.

Here's what I have:

In a formula called InitTicketList, it is "declared" like this:

WhilePrintingRecords; Global StringVar TicketList := "";

This formula field is on the report in Group Header #2a.

Formula UpdateTicketList is declared like this:

WhilePrintingRecords; Global StringVar TicketList; StringVar item := Split({Command.TicketNumber}, ".")[UBound (Split({Command.TicketNumber}, "."))]; if InStrRev(TicketList, item) <= 0 then TicketList := TicketList +item + "; ";

I believe the logic here is correct for two reasons: I have tested it with data and it works. What it does is append one instance of the second section of a number formatted like xxx.xxxxxxxxxxxxxxxxx into TicketList. The idea is to display a list of all those parts, displaying each part only once. Also, this report works perfectly as long as it is one page long.

UpdateTicketList is on the report in Details e.

Finally, ShowTicketList looks like this:

WhilePrintingRecords; Global StringVar TicketList;

and it is on the report in Group Footer #2b.

There is also a ClearTicketList formula, also in Group Footer #2b. It looks like this:

WhilePrintingRecords; Global StringVar TicketList :="";

However, I have removed ClearTicketList as an experiment and the report behavior was still the same.

I'm looking for something or someone that can explain this behavior to me. I don't know if I understand Crystal Report's 3-phase report engine well enough to reason this out. I'm unfortunate in that I maintain Crystal Reports I didn't write and my Crystal-Fu is not very deep.

My goal is to have this formula work for a report of any number of pages and any number of groupings.


While it appeared as if the global variable resets after each page, that is not the whole story. The detail section was suppressed, making it hard to see what happens. It was actually resetting after each detail record that have a blank value in {Command.TicketNumber} and this happened to coincide with a new page. Of course this threw off the UpdateTicketList formula a bit. I modified it to:

WhilePrintingRecords; Global StringVar TicketList; StringVar item := Split({Command.TicketNumber}, ".")[UBound (Split({Command.TicketNumber}, "."))]; if InStrRev(TicketList, item) <= 0 then TicketList := TicketList +item + "; " else TicketList := TicketList

Now it truly only resets once per page.


In all formulas where the variables are reset there has to be adequate checks in place to makes sure the resetting only happens on first record and not for example on every page, like this:

If OnFirstRecord Then Global StringVar TicketList := "";

Other functions that might be possible for different checkings are for example:<br />GroupNumber<br />Next<br />Previous<br />RecordNumber


  • Copy Entire Row (Values not formulas) VBA
  • VBA Vloopup using 2 different workbooks
  • Use VBScript to Merge all open instances of Notepad.exe and save to txt file
  • Loop table rows in Access, with or without use of Private Const
  • How to create a Collection in Firestore with node.js code
  • VBA find function getting error 424 object required [duplicate]
  • VBA count non empty elements of array
  • Use of Java generics could be hanging the compiler
  • how to make union range faster for large loops
  • Python: Split a String Field into 3 Separate Fields using Lambda
  • how can I compare dates in array to find the earliest one?
  • Divide a $1 by 3 and adjusting 1 cent
  • How do I shift the decimal place in Python?
  • Login not working in Firefox in Meteor
  • Inline R code in YAML for rmarkdown doesn't run
  • Thread safety of a fluent like class using clone() and non final fields
  • Retrieve list of sent friend requests from friend_request FQL table
  • MongoDb aggregation
  • Using variable in a value field in jMeter
  • Linq Objects Group By & Sum
  • Retrieving value from sql ExecuteScalar()
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Read text file and split every line in MSBuild
  • How do I fake an specific browser client when using Java's Net library?
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Apache 2.4 - remove | delete | uninstall
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • KeystoneJS: Relationships in Admin UI not updating
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Hits per day in Google Big Query
  • embed rChart in Markdown
  • Checking variable from a different class in C#
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal
  • How to push additional view controllers onto NavigationController but keep the TabBar?