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 gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remaining Text does not appear problem 2

Status
Not open for further replies.

Cpreston

MIS
Mar 4, 2015
972
GB
Hi

I am not the best at Crystal Syntax and I know the following is bad syntax. But I cannot seem to get away for the code to work after many google searches. Basically, I am looking at 3 different fields and if they are blank then Stock if not then the filed entry. The last one is just a number 1 for Various in the field so I want it to return various. Not sure how to make this happen. Any help would be appreciated, thanks

if(isnull({148_vwWorksOrderReportFeed.Expr6})) then
"STOCK"
else
{148_vwWorksOrderReportFeed.Expr6}

if(isnull({WorksOrderHeader.udfCustomer})) then
"STOCK"
else
{WorksOrderHeader.udfCustomer}

if(isnull({worksorderheader.Various})) then
"STOCK"
else
{worksorderheader.udfCustomer} "Various
 
I have tried to follow a similar post on here and got my code like the below but it is string is required on the last IF on the last line. The return of this value s ) for not ticked and 1 for ticked, if it is one I want it to say Various. I keep working at it but if anyone sees how wrong I am going please let me know [bigsmile]

if(isnull({148_vwWorksOrderReportFeed.Expr6})) then "STOCK" AND
IF (isnull({WorksOrderHeader.udfCustomer})) then "STOCK" AND
if(isnull({WorksOrderHeader.udfCustomerVarious})) then
"STOCK"
else
IF (not isnull({148_vwWorksOrderReportFeed.Expr6})) then {148_vwWorksOrderReportFeed.Expr6}
Else
IF (not isnull({WorksOrderHeader.udfCustomer})) then {WorksOrderHeader.udfCustomer}
Else
IF (not isnull({WorksOrderHeader.udfCustomerVarious})) then {WorksOrderHeader.udfCustomerVarious}
 
I have also tried this but ti says it is missing a Then at the end of the last line. I have also created single formula's which all work, it is just joining them all together so they work as one

if(isnull({148_vwWorksOrderReportFeed.Expr6})) AND
if (isnull({WorksOrderHeader.udfCustomer}))AND
(({WorksOrderHeader.udfCustomerVarious})) = False
then
"STOCK"
else
if(not isnull({148_vwWorksOrderReportFeed.Expr6})) Then {148_vwWorksOrderReportFeed.Expr6} and
if (not isnull({WorksOrderHeader.udfCustomer}))Then {WorksOrderHeader.udfCustomer} AND
IF (({WorksOrderHeader.udfCustomerVarious})) = True Then {WorksOrderHeader.udfCustomerVarious}
 
The way you describe this it is an OR condition.

I don't know the CR syntax but logically

If expression1 OR expression2 OR expression3 Then...

...where an expression returns True or False.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

You Matter...
unless you multiply yourself by the speed of light squared, then...
You Energy!
 
It is impossible to troubleshoot what you have presented without understanding exactly what logic you are trying to apply.

As to why the latest code fails, it is because of the line:

"if(not isnull({148_vwWorksOrderReportFeed.Expr6})) Then {148_vwWorksOrderReportFeed.Expr6} and"​

, specifically the 'and'.

After a 'Then' either the code must finish, or be followed by an 'Else'.

I would suggest explaining the logic in words and we can try and turn that into code for you.

Mixing ANDs with ORs can be a challenge. My approach is always to use brackets to force the order of evaluation. Personally, I find formatting the code using indents makes it much easier to read and ensure the correct logic has been applied. Something like this for example:

Code:
IF	(
		x = y and
		(
			a = b or
			c = d
		)
	)
THEN	{result}
ELSE	{other result}

Hope this helps

Cheers, Pete
 
This is probably not going to give you the result you are looking for but it should at least be accepted by Crystal Reports without error.

Code:
IF 	isnull({148_vwWorksOrderReportFeed.Expr6}) 	AND
	isnull({WorksOrderHeader.udfCustomer})		AND
	{WorksOrderHeader.udfCustomerVarious} = False
THEN	"STOCK"
ELSE	
IF	not(isnull({148_vwWorksOrderReportFeed.Expr6})) 
THEN 	{148_vwWorksOrderReportFeed.Expr6} 
ELSE	
IF 	not(isnull({WorksOrderHeader.udfCustomer}))
THEN 	{WorksOrderHeader.udfCustomer} 
ELSE
IF 	{WorksOrderHeader.udfCustomerVarious} = True 
THEN 	{WorksOrderHeader.udfCustomerVarious}

Again, explaining the logic in simple words so we can turn it into working code is probably the best way forward.

Pete
 
Hi

pamx9999 I tried your code but changed the AND's to OR but I am getting a message saying a string is required on the last IF, any ideas

I will also try and explain what I need.

We have a works order and on the order header it displays if the order is for Stock or for a specific customer.
1. To get this it looks on the Works Order to see if a sales order number is if there is one it displays the customer name, if there is not a sales order number it displays stock.
({148_vwWorksOrderReportFeed.Expr6})
We now have a couple of new fields which we need to take into account when entering a works order and they follow the same principle
2. If 1 is blank to look at udfcustomer to see if that is blank. if there is a name there it needs to display on the header with the customer name if blank it needs to be stock
{WorksOrderHeader.udfCustomer}
3. If 1 and 2 are blank to look at udfCustomerVarious to see if true then it needs to display Various if false then Stock. This is is just or 1 in the databse but I want it ti disolay Various if = 1
WorksOrderHeader.udfCustomerVarious

Hope that explains it

Many thanks for your replies, I will try and see if I can crack it during the day, there may be a time difference between our locations


 
Sorry in number 3 it should read

3. If 1 and 2 are blank to look at udfCustomerVarious to see if true then it needs to display Various if false then Stock. This is is just or 1 or 0 in the database but I want it to display Various if = 1
WorksOrderHeader.udfCustomerVarious
 
Hi

Ok my code is looking as below now, I am getting an error The keyword 'then' is missing after the "Various", exhausted all ideas on this. Close but no cigar unless I am way off base with what I am doing , any ideas please people.

IF (isnull({148_vwWorksOrderReportFeed.Expr6})) OR
IF (isnull ({WorksOrderHeader.udfCustomer})) OR
IF (({WorksOrderHeader.udfCustomerVarious})) = False
Then "Stock"
Else
IF not isnull({148_vwWorksOrderReportFeed.Expr6})
THEN {148_vwWorksOrderReportFeed.Expr6}
Else
IF not isNull({WorksOrderHeader.udfCustomer})
Then {WorksOrderHeader.udfCustomer}
Else
If {WorksOrderHeader.udfCustomerVarious} = True
Then "Various
 
Does my re-doing of your description still sound correct. In my experience, Crystal checking for nulls/negatives first tends to return the most accurate results.

1. If no Customer Name and no udfcustomer name and udfcustomervarious is false (non-boolean 0?) then Stock
2. If no Customer Name and no udfcustomer name and udfcustomervarious is true (non-boolean 1?) then Various
3. If no Customer Name and udfcustomer name exists then udfcustomer name
4. if Customer Name exists then Customer Name

If the above is correct then this should get you close. It is untested and may contain typos.
Code:
IF (
(isnull({148_vwWorksOrderReportFeed.Expr6})) 
AND
(isnull ({WorksOrderHeader.udfCustomer}))
AND
NOT(({WorksOrderHeader.udfCustomerVarious} = 1) //---->or 1 or T or whatever the value in the databae for true is if it is not boolean
)
THEN
"Stock"
Else
IF (
(isnull({148_vwWorksOrderReportFeed.Expr6})) 
AND
(isnull ({WorksOrderHeader.udfCustomer}))
AND
(({WorksOrderHeader.udfCustomerVarious} = 1) //---->or 1 or T or whatever the value in the databae for true is if it is not boolean
)
THEN
"Various"
Else
IF (
(isnull({148_vwWorksOrderReportFeed.Expr6})) 
AND
NOT(isnull ({WorksOrderHeader.udfCustomer}))
)
THEN
{WorksOrderHeader.udfCustomer}
Else
IF (
NOT(isnull({148_vwWorksOrderReportFeed.Expr6})) 
)
THEN
{148_vwWorksOrderReportFeed.Expr6}
Else
"None"
 
HI

Thanks fisheromacs I adapted a few areas it complained about (typos) but I think that has worked. I need to test on a wider scope of works order numbers but the 3 I have tested for each possible scenario has worked. Will get more testing done and inform back. Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top