473,473 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create 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.Business Impact Vector}<=14 AND {Calculations.Total Spend CY}<=2 Then "Tier 4"
Else

If {Calculations.Business Impact Vector}<=21 AND {Calculations.Total Spend CY}<=10 Then "Tier 3"
Else

If {Calculations.Business Impact Vector}<=28 AND {Calculations.Total Spend CY}<=100 Then "Tier 2"
Else

If {Calculations.Business Impact Vector}=28 AND {Calculations.Total Spend CY}>100 Then "Tier 1"
Oct 1 '07 #1
4 1787
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...where 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...where 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
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...
9
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
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...
39
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...
0
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...
20
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...
2
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...
3
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...
0
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...
0
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...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.