Solved

"IF Statement" in Crystal report...

Posted on 2000-04-14
12
219 Views
Last Modified: 2010-05-02
I want to write query like this:

If {Site.Group} = "Bldg" then
     Site.name = Site.name
Else
     Site.name = ""
End if
     
Where "site" is tablename and "Group","name"  is field of that table.It contains 3 different kind of values.If its value is "Bldg" than only it retrieves data from "site.name" field.Otherwise it doesn't show anything in report.That's it.

Let me know step by step how i put "site.name" field in my report ?

Thanks for your time in advance.

Thanks,
bhavesh55
0
Comment
Question by:bhavesh55
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 1

Expert Comment

by:ndb
ID: 2716501
Instead of draging a databasefield in your report, you should make a Formula with the following:

If {Site.Group} = "Bldg" then
     Site.name
Else
     ""
End if
     
0
 

Accepted Solution

by:
marcosjimenez earned 40 total points
ID: 2716504

 Put a Formula Field on your report and type this in the formula text:

If {Site.Group} <> "Bldg" then
    txtSite.name = ""     
else
    txtsite.name = {Site.Group}


where txtSite is the Formula Field.
0
 

Author Comment

by:bhavesh55
ID: 2716626
marcosjimenez
From "insert" menu, i choose "Formula Field".Than "Field Explorer" pops up and using right click menu i select "New" and enter "txtSite" as you told me.

And wrote below mentioned text in Formula Editor:
If {Site.Group} <> "Bldg" then
    txtSite.name = ""
else
    txtSite.name = {site.name}


Error:
1)There is an error in this formula.Do you want to save it anyway ?

2)A number,currency,amount,boolean,date,time,date-time, or string is expected here.

Let me know how should i fix this ?
I am really in hurry.

Thanks,
bhavesh55
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bhavesh55
ID: 2717113
ndb,marcosjimenez & other experts
I am eagerly waiting for your reply.

Let me know as soon as you can.

Thanks,
bhavesh55
0
 
LVL 32

Expert Comment

by:Brendt Hess
ID: 2717175
For a crystal formula, you don't have assignments.  Try this:

If {Site.Group} = "Bldg" then
     {Site.name}
Else
    " "

0
 
LVL 1

Expert Comment

by:ndb
ID: 2717176
Have you tried this formula?

If {Site.Group} = "Bldg" then
     {Site.name}
Else
     ""
End if

I use something like this in my own reports and it works.
0
 

Author Comment

by:bhavesh55
ID: 2720611
I would like to give points to ndb and bhess1.

It shouldn't show me that option.

Let me know what should i do to give them points.

0
 
LVL 1

Expert Comment

by:ndb
ID: 2720900
Well ... spliting the points of a question isn't possible.
The only thing you could do is requesting a deletion request on this question a ask two new questions with half the points on it.
0
 

Author Comment

by:bhavesh55
ID: 2722979
bhess1
May i know the exact syntax for the "Else if" statement also.

Is this the right one ?

If {Site.Group} = "Bldg" then
     {Site.name}
Else if {Site.Group} = "Tenant" then
     {Site.name}
Else
    " "

When i try to run above one than it gives me error like:

"The remaining text does not appear to be part of the formula".

I am eagerly waiting for your reply.
Thanks,
bhavesh55



0
 
LVL 1

Expert Comment

by:ndb
ID: 2723124
If {Site.Group} = "Bldg" then
     {Site.name}
Else
    if {Site.Group} = "Tenant" then
        {Site.name}
    Else
        " "

0
 
LVL 32

Expert Comment

by:Brendt Hess
ID: 2723356
ndb has it right.

Also, you can write this as one IF statement:

If {Site.Group} = "Bldg" OR {Site.Group} = "Tenant" then
     {Site.name}
Else
     " " 
0
 
LVL 32

Expert Comment

by:Brendt Hess
ID: 2723384
IMO, the only reasonable way to give two people points is to post another question with 'For ndb' or 'For bhess1' as the title, and offer more points.  

IMO, deleting the question affects how EE works... the archive of historical answers is a valuable resource for others, and should be kept intact if possible.

You might offer a suggestion to EE that allowing split points on the answer to a question would be useful - allow us to check all of the pieces that we feel answered the question, and split the points evenly between the answerers.

Hmmm... I think I'll suggest that myself!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 11 hours left to enroll

635 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