crystal with parameters question...

E

Eych

I've got two parameters on my report titled "CustName" and
"OrderID"...both are in the Details section...however, only one
parameter works, the other doesn't...

sample code:

Dim param1 As New ParameterField
Dim param2 as New ParameterField
Dim paramValue As New ParameterDiscreteValue
(tbCustomers is set to a datatable which is filtered to contain 1
record)
(tbOrders is set to a datatable which is filtered to contain all orders
for customer in tbCustomers)

param1.ParameterFieldName = "CustName"
paramValue.Value = tbCustomers.Rows(0).Item("FullName")
param1.CurrentValues.Add(paramValue)

param2.ParameterFieldValue = "OrderID"
paramValue.Value = ??? (need all OrderID's from tbOrders)
param2.CurrentValues.Add(paramValue)


param1 works because it is set to a specific field in a table.
however, I'm not sure how to assign the value of param2, since there
will be several results.

thanks...
 
A

Andy O'Neill

Eych said:
I've got two parameters on my report titled "CustName" and
"OrderID"...both are in the Details section...however, only one
parameter works, the other doesn't...

sample code:

Dim param1 As New ParameterField
Dim param2 as New ParameterField
Dim paramValue As New ParameterDiscreteValue
(tbCustomers is set to a datatable which is filtered to contain 1
record)
(tbOrders is set to a datatable which is filtered to contain all orders
for customer in tbCustomers)

param1.ParameterFieldName = "CustName"
paramValue.Value = tbCustomers.Rows(0).Item("FullName")
param1.CurrentValues.Add(paramValue)

param2.ParameterFieldValue = "OrderID"
paramValue.Value = ??? (need all OrderID's from tbOrders)
param2.CurrentValues.Add(paramValue)


param1 works because it is set to a specific field in a table.
however, I'm not sure how to assign the value of param2, since there
will be several results.

thanks...

I don't think you've told us enough about what you're trying to do in order
to give a definitive answer.

The way I prefer to do crystal reports is to base them on stored procedures.
If I have guessed correctly as to what you're doing I'd have a like
comparison for the order id and stick in "%" when I wanted everything.
If I haven't guessed right then that might be no good...
 
E

Eych

Andy,

Thanks for replying.

This is the result I'm looking for

John Smith
Order# 124
Order# 233
Order# 455

if I do
paramValue.Value = tbOrders.Rows(0).Item("OrderID")
then I get

John Smith
Order# 124
Order# 124
Order# 124

this is because I gave a specific (Rows(0)) value to the parameter.
However, I just want to link the "OrderID" field in tbOrders to the
value of the parameter so that it displays all of the records.

Thanks
 
A

Andy O'Neill

Eych said:
Andy,

Thanks for replying.

This is the result I'm looking for

John Smith
Order# 124
Order# 233
Order# 455

if I do
paramValue.Value = tbOrders.Rows(0).Item("OrderID")
then I get

John Smith
Order# 124
Order# 124
Order# 124

this is because I gave a specific (Rows(0)) value to the parameter.
However, I just want to link the "OrderID" field in tbOrders to the
value of the parameter so that it displays all of the records.

Thanks

I think it's more the other way round mate.
IF what you want is to select all the orders for one customer.
then you COULD use customer id as a parameter for both.

I am assuming customer id or some such is a foreign key in orders.
If it ain't then you got a VERY bad database design as you don't know who
any order is for!!!


BUT.
The two tables and two parameters aren't, IMO, the best way to use crystal.


I'd have a piece of sql links the two tables on customer.

Something like.

select o.blaa, c.blaa, from orders o inner join customers c
on c.customerId = o.customerId
where c.customer=@parameter

I'd make that a stored procedure and base the report on that.
Where you have a datatable then you have some sql used to make the thing.
The above is sql....

You set the customer id and the sql picks both stuff out both tables for
you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top