Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a custom range parameter. HELP! 2

Status
Not open for further replies.

wanamingo

Technical User
Oct 11, 2012
8
US
So I am trying to make a very simple report that simplifies our companies serial labeling system. The part Im stuck at is the manual entry of a range of numbers.

For example if a user needs to reprint a few labels that are in consecutive numeric order (for example the SN's 1,2,3,4,5,6,7,8,9,10). Unfortunately when I make a parameter of CustomSerial with a multiple and range entry nothing shows up. These serial numbers are also not in a database every single time, many parts are serialized after they have received their serial labels.

If I enter any range or more than one number the entire field disappears from the report, every label is blank. Ive also posted this question in Crystal Reports 4 Other Topics.
 
i would probably try to do 2 parameters, a start # and a # of labels, then a formula to increment up and display.
 

Here's my first thought; others will probably come up with alternate approaches.

Create a command object, use any data source, that creates a variable table and populates it with the most number of labels you'll ever need:

Code:
declare @v_values table
(rowid int)

declare @x int
set @x = 1

while @x < 100 --change this value to suit your needs

BEGIN
insert into @v_values (rowid) values (@x)
set @x = @x + 1
END

select * from @v_values

If you drop the rowid field into the report you'll get one record for every value in the table - in my example it's 100. Restrict the report to the number of records you actually need by entering this in the record selection formula:

{Command.rowid} <= (maximum({?Your Parameter}) - minimum({?Your Parameter})) + 1

Now get rid of the rowid field in the report and replace it with this formula:

whileprintingrecords;
numbervar v_label := minimum({?My Parameter});
v_label := v_label + ({Command.rowid} - 1)


You just want the sequential label numbers on the report, right?
 
Hey thanks for getting back to me. Im afraid im not sure how to create a command object (Im using crystal 11.5)....

I completely understand where you are going but am getting a little hung up. Could you please exlpain how to create a command object?
 

Create a blank report and connect it to any data source - it won't matter, since you won't be using any database fields. Once connected, in the Database Expert the first item will be Add Command. Double click it to open a dialog where you can paste in any valid SQL statement that returns a recordset.

Paste in your code and click OK. CR will check the syntax, and then you'll see 'Command' where you would expect to see tables added to the report. A command behaves exactly like a table - you can join other tables to it, etc.

The code I provided is SQL Server syntax, so you'll need to connect to a SQL Server. Otherwise you'll have to tweak it for your database platform.

Commands are very useful, depending on how comfortable you are writing SQL.
 
Brian Griffin is a GENIUS! Not only did you really help me out but you have certainly taught me some new tricks. I can not thank you enough for your help.

Ill be pointing people towards these boards because the level of help I received was amazing.
 

"A genius is a guy like Norman Einstein." - Joe Theisman

I've been relying on this forum for at least a decade, and have received much more help than I've given. Happy to pay that back in part.

 
I wish this method worked with my DB .... would solve a lot of issues for me.

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top