Avatar of Ess Kay
Ess Kay
Flag for United States of America asked on

Crystal Reports sub report issue

Dear Experts,


I have a report with a date parameter
screenshot 1
it passes it to the subreport


subreport has a query with a parameter

subreport param
the query is



 select distinct invntryitm_id,serial,itemdesc  from (
SELECT DISTINCT ABCOSPRO_EQTOOL.invntryitm_id, ABCOSPRO_EQTOOL.serial, ABCOSPRO_EQTOOL.itemdesc, ABCO_Inv_batch.date,case when ABCO_Inv_batch.date is null then '' else ABCO_Inv_batch.date end as thedate
FROM         ABCO_Inv_data INNER JOIN
                      ABCO_Inv_batch ON ABCO_Inv_data.batch_rn = ABCO_Inv_batch.batch_rn FULL OUTER JOIN
                      ABCOSPRO_EQTOOL ON ABCO_Inv_data.serial = ABCOSPRO_EQTOOL.serial
WHERE     (ABCOSPRO_EQTOOL.serial LIKE '%') AND (ABCOSPRO_EQTOOL.serial <> ''))x
where thedate not in  ({?Pm-@qdate} )
and serial not in (
SELECT DISTINCT ABCOSPRO_EQTOOL.serial
FROM         ABCO_Inv_data INNER JOIN
                      ABCO_Inv_batch ON ABCO_Inv_data.batch_rn = ABCO_Inv_batch.batch_rn FULL OUTER JOIN
                      ABCOSPRO_EQTOOL ON ABCO_Inv_data.serial = ABCOSPRO_EQTOOL.serial
WHERE     (ABCOSPRO_EQTOOL.serial LIKE '%') AND (ABCOSPRO_EQTOOL.serial <> '') and convert(varchar(50),date) =  ({?Pm-@qdate} ))








-------------
for some reason if I enter the date 3/19/2012 the main report takes it but the subreports sees 04/12/3765 or something


??wtf


someone please help

Thanks in advance
Crystal ReportsMicrosoft SQL Server

Avatar of undefined
Last Comment
James0628

8/22/2022 - Mon
Mike McCracken

How are you linking the reports?

Can you upload the report?

mlmcc
Ess Kay

ASKER
ASKER CERTIFIED SOLUTION
Kyle Abrahams

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Mike McCracken

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
James0628

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ess Kay

ASKER
Ive tried several things with it. This is why it may seem confusing.




1st I passed just the regular date value straight to the subreport @date
then converted it to a string in the query. this was changed to ?pm-@date

then i tried converting it to text in the formula as @qdate and passing it
a) straight to the query as a parameter.  ?pm-qdate
b) used as a formula to change back to date and pass to query
?pm-qdate..01


the query in the subreport works fine actually as you can see from the screenshot. the values get passed incorrectly between them

it appears that the number gets deranged when it gets passed to the subreport regardless of how i format it



This is its use in the SUBQUERY
subquery
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Mike McCracken

You have to pass the date in the proper format to the parameter fromthe COMMAND.

You are getting the wierd values because the command parameter has a default value.

Edit the command and delete the default value from the parameter.  I had a similar issue and the only way around it was to not have a default value for the parameters.

mlmcc
Ess Kay

ASKER
i always left the default empty

default field
Ess Kay

ASKER
strange I reapplied the parameters another ten times and it started to work again.


linked the parameters straight from the report this time and its starting to pull correct data



works now


still not clear of what the problem was, but i think i should just stop touching it and step away
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ess Kay

ASKER
God I hate SAP always some problems with their programs

thanks for taking the time out of your lives to try to help me guys
James0628

Ah.  I hadn't noticed that you were using a Command in the subreport, so I didn't realize that you were using the parameter there.  It seems like the report that you posted should have been prompting you for the subreport parameter.  That issue aside, I don't know why simply linking from the main report parameter to the subreport one wouldn't work (or why you would have trouble getting it to work).  If you're converting the date parameter to a string in the report, and converting a date field to a string in the Command, then you need to make sure that both conversions use the exact same format, since you're going to be comparing strings.  But that wouldn't explain the strange dates you were seeing.


 This is unrelated, but FWIW ...

 You used this in 2 WHERE's in the subreport Command:

(ABCOSPRO_EQTOOL.serial LIKE '%') AND (ABCOSPRO_EQTOOL.serial <> '')

 I think you could simplify that to

(ABCOSPRO_EQTOOL.serial LIKE '_%')

 That should match a serial that is one or more characters, which seems to be what the first 2 tests are doing.

 James
Mike McCracken

ONe thing to try, delete the parameter in the command and add it back in with a more conventional name.

Also, unless the field in the database is a string, there is no reason to convert the date from the main to a string.

mlmcc
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Ess Kay

ASKER
James, thanks for that idea  i just dont want it to be null or blank, your way is simpler

mlmcc,

1_  the fields in the database are strings. i have to convert them to date so that the user can have a dropdown calender to select a date then convert it back to a string

2_  if i add a 'more conventional name' it gives me two parameters to enter in the beginning instead of one.
it has to match.  or thats a whole different problem. the reason it ended as {?Pm-@qdate??1} is because

(and FYI)

{?Pm-@qdate??1} breakdown:
?PM means its a parameter
@ means the value i passed was a formula
qdate is the actual formula i pass
??1   means its the second parameter named like that because the first didnt work the first one is actually ?Pm-@qdate
James0628

It seems like there should be a more direct way to handle this, although since you're using MS SQL, a date (as opposed to datetime) parameter could be a problem, since MS SQL didn't have a date data type until SQL Server 2008.  I don't know if you could drop a date parameter into a Command with the earlier versions.

 If nothing else, I would think that you could use a string parameter in the subreport Command and a date parameter in the main report, use a formula in the main report to convert the date parameter to a string, and link that formula to the string parameter in the subreport.  You would just need to make sure that CR produced a date string that was in the exact same format as the date strings in your db.

 James
Ess Kay

ASKER
works fine now, im afraid if i change something it might hiccup again
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
James0628

I get that, but thought I'd throw that out there.  Maybe next time it decides to act up.  :-)

 James