?
Solved

Create a Array start # to end # In Crystal

Posted on 2014-04-02
4
Medium Priority
?
351 Views
Last Modified: 2014-04-02
I have yet another crazy Crystal approach where a SQL table {dbo.sales} timestamps a batch of created ticket numbers for example a sale where a client purchased qty 50 tickets on datetime and the starting number is 12340 and ending number 12389.

I have another table {dbo.transactions} when these actual tickets are being used for example on {dbo.datetime} ticket number 12341 was used.

I want to create a Crystal formula (@TicketSold) where the ticket number used checks the {dbo.Sales} table or however and shows the date when this 'used ticket' was created.

I'm guessing that each time tickets are sold (qty) I want to create an array reference with that date for the start to end numbers.
0
Comment
Question by:John-S Pretorius
  • 2
  • 2
4 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 39972827
Is there a single record in the dbo.sales table for the entire transaction or does each ticket have its own record.

If each ticket sold has a record then simply add the sales table and link on the ticket number to the transaction table.
There will be no lookup as you see just use the date sold field in the report.

 If there is a range you have other options
1.  Use a SQL Expression
2.  Use a subreport linked on the ticket number
3.  Use a Crystal Command

What database do you have?
If it is Oracle the first option is probably not available.

The third will be something like

SELECT dbo.transactions.ticketNumber, dbo.transactions.transactiondate, dbo.sales.salesdate, other fields you need
FROM dbotransactions INNER JOIN dbo.sales ON dbo.transactions.ticketnumber >= dbo.sales.ticketnumberfirst AND dbo.transactions.ticketnumber <= dbo.sales.ticketnumberlast

You may have to do the join  filter in the where clause
SELECT dbo.transactions.ticketNumber, dbo.transactions.transactiondate, dbo.sales.salesdate, other fields you need
FROM dbotransactions, dbo.sales
WHERE
dbo.transactions.ticketnumber >= dbo.sales.ticketnumberfirst AND dbo.transactions.ticketnumber <= dbo.sales.ticketnumberlast

mlmcc
0
 

Author Comment

by:John-S Pretorius
ID: 39972851
It is a SQL Database and each sale is typically part of a range, so if just ticket is being sold it's ok since the {dbo.FromNumber} and the {dbo.ToNumber} will be the same but if the quantity is more than 1 I just have a datetime stamp with a quantity.

Would another approach be possible to have a looped Array "FromNumber' to 'ToNumber as a global variable which runs against all sales in a subreport.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 39973238
Crystal works on 1 record at a time so looping really doesn't exist.

You can try a SQL expression

(
   SELECT   dbo.sales.CustomerID FROM dbo.sales WHERE dbo.sales.FromNumber <= {dbo.transaction.TicketNumber} AND dbo.sales.ToNumber >= {dbo.transaction.TicketNumber}
)

You can also use a subreport.
Link it on the ticket number
selecting on FromNumber

You can then edit the selection formula in the subreport to be

dbo.sales.FromNumber <= {?pm_TickectNumber} AND dbo.sales.ToNumber >= {?pm_TickectNumber}


mlmcc
0
 

Author Closing Comment

by:John-S Pretorius
ID: 39973259
Thank you
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question