473,581 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If then statements

9 New Member
I am an avid user of Crystal Reports. I'm in a new job that is requiring me to build an access database. I know that I can write a formula in Crystal to accomplish what I am looking for, however, I would prefer this data to be stored in a table.

This is how my formula is written in Crystal: I would like this to be automatically calculated based on data that is gathered using a form and then stored in a table. I am beside myself trying to figure this out.

Any suggestions?

If {Calculations.B usiness Impact Vector}<=14 AND {Calculations.T otal Spend CY}<=2 Then "Tier 4"
Else

If {Calculations.B usiness Impact Vector}<=21 AND {Calculations.T otal Spend CY}<=10 Then "Tier 3"
Else

If {Calculations.B usiness Impact Vector}<=28 AND {Calculations.T otal Spend CY}<=100 Then "Tier 2"
Else

If {Calculations.B usiness Impact Vector}=28 AND {Calculations.T otal Spend CY}>100 Then "Tier 1"
Oct 1 '07 #1
4 1793
MMcCarthy
14,534 Recognized Expert Moderator MVP
Assuming Calculations is a table and Business Impact Vector and Total Spend CY are fields in that table then you can design a query as follows:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. IIf([Business Impact Vector]<=14 AND [Total Spend CY] <=2, "Tier 4",
  3. IIf([Business Impact Vector]<=21 AND [Total Spend CY] <=10, "Tier 3",
  4. IIf([Business Impact Vector]<=28 AND [Total Spend CY] <=100, "Tier 2",
  5. IIf([Business Impact Vector]=28 AND [Total Spend CY] >10, "Tier 1"))))
  6. FROM Calculations
  7.  
However, I think you have a problem with your logic. If [Business Impact Vector] =10 and [Total Spend CY]=2 then this will hold true for all of the first three conditions.

The syntax for an If statement is ...

IIF(<Condition> ,<value if true>,<value if false>)
Oct 1 '07 #2
sshafer1
9 New Member
Thanks! One more question...wher e do I add this expression? I dropped an unbound text field to my form and added the code below to the 'Expression Builder' in the Control Source property. When I view the form, the following populates the text box '#Name?'.

1. How do I correct this so that I can see the 'Tier #' in the box?
2. How do I set this up to write to a table?

Once I have this, I can re-use it for a bunch of other things I'm working on.

IIf([Business Impact Vector]<=14 AND [Total Spend CY] <=1000000, "Tier 4",
IIf([Business Impact Vector]<=21 AND [Total Spend CY] <=2000000, "Tier 3",
IIf([Business Impact Vector]<=28 AND [Total Spend CY] <=5000000, "Tier 2",
IIf([Business Impact Vector]=28 AND [Total Spend CY] >5000000, "Tier 1"))))

Thanks!
Oct 2 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Thanks! One more question...wher e do I add this expression? I dropped an unbound text field to my form and added the code below to the 'Expression Builder' in the Control Source property. When I view the form, the following populates the text box '#Name?'.

1. How do I correct this so that I can see the 'Tier #' in the box?
2. How do I set this up to write to a table?

Once I have this, I can re-use it for a bunch of other things I'm working on.

IIf([Business Impact Vector]<=14 AND [Total Spend CY] <=1000000, "Tier 4",
IIf([Business Impact Vector]<=21 AND [Total Spend CY] <=2000000, "Tier 3",
IIf([Business Impact Vector]<=28 AND [Total Spend CY] <=5000000, "Tier 2",
IIf([Business Impact Vector]=28 AND [Total Spend CY] >5000000, "Tier 1"))))

Thanks!
The two fields [Business Impact Vector] and [Total Spend CY] have to be in bound controls on the form also and make sure the controls have the same name.
Oct 2 '07 #4
sshafer1
9 New Member
Ok. That helps. I added the IIF statement as a Query field and defined the query field value as TierEx: then put the IIF statement in. Doing this at least generated the correct value that I was looking for.

However, Calculated is really a query not a table. I am calculating [Business Impact Vector] and [Total Spend CY] in a query because they are adding multiple question responses together from a form.

How can I write the calculated values from the query to a table?

Your help is greatly appreciated!
Oct 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2496
by: Bart Nessux | last post by:
Should an if statement have a corresponding else statement? Or, is it OK to have an if statement by itself. For completeness, it seems the two should be together, but from experience I know that a if statement by itself works just fine. Below is an example: if x >=0: DO SOMETHING Would it be better, or perhaps more complete, written like...
9
2625
by: Jaime Wyant | last post by:
I know I've seen this somewhere, but can't seem to google it. Is there a way to use an alternate statement separator, other than the default ';'? jw
1
3802
by: Tom D | last post by:
I'm rewriting a database interface that our company currently has. Currently it's using the Pear::DB interface, but we found that that was introducing a bit too much overhead. I'm rewriting the interface to use mysqli. Most of what the interface does is to simplify getting results in the form of arrays (ordered and associative). Most of the...
39
6820
by: slogging_away | last post by:
Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32, and have a script that makes numerous checks on text files, (configuration files), so discrepancies can be reported. The script works fine but it appears that I may have hit a wall with 'if' statements. Due to the number of checks perfromed by the script on the text files,...
0
1843
by: Fuzzyman | last post by:
Hello all, The following is a copy of a blog entry. It's asking a question about future statements and the built in compile function. I'd appreciate any pointers or comments about possible approaches. `Movable Python <http://www.voidspace.org.uk/python/movpy/>`_ supports running both Python scripts and ``.pyc`` bytecode files. It does...
20
2007
by: Neroku | last post by:
Hello, i would like to know what the serious definition of statements and expressions is: i know an expression are evaluated to a value, i.e: 1 == 2 5+7 foo( 1,2) and a statement is executed: break;
2
2724
by: ojorus | last post by:
Hi! Some questions regarding the mysqli-extension (php5) 1) Prepared statements: If I understand things right, prepared statements will give better performance if you make several similar querys. (where you only change the parameters) But what if you do only ONE query; will it then be usefull to use prepared statements? Can it actuelly give...
3
6593
by: Dmitri | last post by:
Hello! I have a developer that is playing around with some SQL statements using VB.NET. He has a test table in a SQL 2000 database, and he has about 2000 generated INSERT statements. When the 2000 INSERT statements are run in SQL query analyzer, all 2000 rows are added to the table. When he tries to send the 2000 statements to SQL Server...
0
1911
by: Gary Herron | last post by:
Ohad Frand wrote: There is no way you can consider 'elif', 'else', 'except', and 'from' statements. However, as someone pointed out, the kwlist from the keyword module is the closest thing we can think of to the list you are asking for. On the other hand, what's wrong with constructing the list as you did in your example above?
0
1441
by: Ohad Frand | last post by:
Hi Thanks a lot for your reply I think the main uses for it is to study the language and to see that I didn't miss anything else or that something is changed from one version to another. The keyword module will help me Thanks again Ohad Frand
0
7882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5683
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.