Solved

Create a Array start # to end # In Crystal

Posted on 2014-04-02
4
339 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 100

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 100

Accepted Solution

by:
mlmcc earned 500 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now