473,787 Members | 2,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expression Builder Question

I am trying to write an expression that converts one set of values to
another. There are two fields, STAGE and ADMIT_TYPE, which are used as
input criteria, and the final converted values are placed in the
APPSTATUS field. The rules for the conversion are as follows:

If STAGE = 600 then APPSTATUS = 03

If STAGE > 300 then APPSTATUS = 01

If STAGE > 300 and ADMIT_TYPE = AF or AFD or AP or APD, then APPSTATUS
= 02

If STAGE < 300 then APPSTATUS = ""
This is the expression I have typed up, but I havn't gotten the right
results:

IIf([STAGE]="600","03",IIf ([STAGE]>"300","01",IIf ([STAGE]>"300" And
[ADMIT_TYPE]= "AF" or "AFD" or "AP" or
APD","02",IIf([STAGE]<"300",""))) )

I have limited experience using most of the code, and though I have
used the IIf statement before, I am not even sure if it is the right
one for this situation. If anyone has a better way to do it or sees
the error in the way I have attempted to do this, please let me know.
Or if this isn't clear enough please let me know and I will try to
explain further. I appreciate any help that you can give!

Fran Zablocki
Nov 12 '05 #1
3 12109
1)You have to repeat the field name for each and/or criteria.
2) If the criteria value (i.e. 600 03, etc.) are numbers, not text, do not
enclose them in quotes.
3) You left out a quote in [Admit_Type] = "APD"
4) Place the and/or's within parenthesis to make what you want clear to
Access.
IIf([STAGE]=600,3,IIf([STAGE]>300,1,IIf([STAGE]>300 And
([ADMIT_TYPE]= "AF" or [Admit_Type] = "AFD" or [Admit_Type] = "AP" or
[Admit_Type] = "APD"),2,II f([STAGE]<300,""))))

5) You don't need to, but I would have moved IIf[Stage]<300 to the first IIf
statement,
or left it out altogether, as if it the other criteria isn't met, nothing
will appear anyway.
IIf([STAGE]=600,3,IIf([STAGE]>300,1,IIf([STAGE]>300 And
([ADMIT_TYPE]= "AF" or [Admit_Type] = "AFD" or [Admit_Type] = "AP" or
[Admit_Type] = "APD"),2,"" )))

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Fran Zablocki" <fe*@buffalo.ed u> wrote in message
news:66******** *************** ***@posting.goo gle.com...
I am trying to write an expression that converts one set of values to
another. There are two fields, STAGE and ADMIT_TYPE, which are used as
input criteria, and the final converted values are placed in the
APPSTATUS field. The rules for the conversion are as follows:

If STAGE = 600 then APPSTATUS = 03

If STAGE > 300 then APPSTATUS = 01

If STAGE > 300 and ADMIT_TYPE = AF or AFD or AP or APD, then APPSTATUS
= 02

If STAGE < 300 then APPSTATUS = ""
This is the expression I have typed up, but I havn't gotten the right
results:

IIf([STAGE]="600","03",IIf ([STAGE]>"300","01",IIf ([STAGE]>"300" And
[ADMIT_TYPE]= "AF" or "AFD" or "AP" or
APD","02",IIf([STAGE]<"300",""))) )

I have limited experience using most of the code, and though I have
used the IIf statement before, I am not even sure if it is the right
one for this situation. If anyone has a better way to do it or sees
the error in the way I have attempted to do this, please let me know.
Or if this isn't clear enough please let me know and I will try to
explain further. I appreciate any help that you can give!

Fran Zablocki

Nov 12 '05 #2
fe*@buffalo.edu (Fran Zablocki) wrote in message news:<66******* *************** ****@posting.go ogle.com>...
I am trying to write an expression that converts one set of values to
another. There are two fields, STAGE and ADMIT_TYPE, which are used as
input criteria, and the final converted values are placed in the
APPSTATUS field. The rules for the conversion are as follows:

If STAGE = 600 then APPSTATUS = 03

If STAGE > 300 then APPSTATUS = 01

If STAGE > 300 and ADMIT_TYPE = AF or AFD or AP or APD, then APPSTATUS
= 02

If STAGE < 300 then APPSTATUS = ""
This is the expression I have typed up, but I havn't gotten the right
results:

IIf([STAGE]="600","03",IIf ([STAGE]>"300","01",IIf ([STAGE]>"300" And
[ADMIT_TYPE]= "AF" or "AFD" or "AP" or
APD","02",IIf([STAGE]<"300",""))) )

I have limited experience using most of the code, and though I have
used the IIf statement before, I am not even sure if it is the right
one for this situation. If anyone has a better way to do it or sees
the error in the way I have attempted to do this, please let me know.
Or if this isn't clear enough please let me know and I will try to
explain further. I appreciate any help that you can give!

Fran Zablocki


Please try this:
IIf([STAGE]=600,"03",IIf(([STAGE]>300 And ([ADMIT_TYPE]="AF" Or
[ADMIT_TYPE]="AFD" Or [ADMIT_TYPE]="AP" Or
[ADMIT_TYPE]="APD")),"02",I If([STAGE]>300,"01","") ))

Xiaolu
Nov 12 '05 #3
fe*@buffalo.edu (Fran Zablocki) wrote in
news:66******** *************** ***@posting.goo gle.com:
I am trying to write an expression that converts one set of
values to another. There are two fields, STAGE and ADMIT_TYPE,
which are used as input criteria, and the final converted
values are placed in the APPSTATUS field. The rules for the
conversion are as follows:

If STAGE = 600 then APPSTATUS = 03

If STAGE > 300 then APPSTATUS = 01

If STAGE > 300 and ADMIT_TYPE = AF or AFD or AP or APD, then
APPSTATUS = 02

If STAGE < 300 then APPSTATUS = ""
This is the expression I have typed up, but I havn't gotten
the right results:

IIf([STAGE]="600","03",IIf ([STAGE]>"300","01",IIf ([STAGE]>"300"
And [ADMIT_TYPE]= "AF" or "AFD" or "AP" or
APD","02",IIf([STAGE]<"300",""))) )

I have limited experience using most of the code, and though I
have used the IIf statement before, I am not even sure if it
is the right one for this situation. If anyone has a better
way to do it or sees the error in the way I have attempted to
do this, please let me know. Or if this isn't clear enough
please let me know and I will try to explain further. I
appreciate any help that you can give!

Fran Zablocki

You might want to create a code module and write a user-defined
function. I find them a lot easier to maintain. Name the module
anything except cvtStage2Appsta tus. I usually have a module
Conversions with several of these functions. They will even appear
in the expression builder. Very handy.

'-------------------------
Public function cvtStage2Appsta tus( _
byval mystage as variant, _
myadmit_type as variant) as variant

select case mystage
case >=600
cvtStage2Appsta tus = 03 ' or "03"
case > 300
select case myAdmit_type
case "AF"
cvtStage2Appsta tus = 02 ' or "02"
case "AFD"
cvtStage2Appsta tus = 02
case "AP"
cvtStage2Appsta tus = 02
case "APD"
cvtStage2Appsta tus = 02
case else
cvtStage2Appsta tus = 01
end select
case 300
'Your choices don't include this.
' Fix by adding an option here, or delete this section and
'modify < 300 to <=300, or >300 to >=300
case else ' <300
cvtStage2Appsta tus = 00 ' or " "
end select
end function
'-------------------------

Use the quoted version if you want a string result, the version as
I have it for a number.

Now in your query grid, call the function as
Appstatus: cvtStage2Appsta tus([Stage],[Admit_type])

Or in a textbox.control source on a form or report
=cvtStage2Appst atus([Stage],[Admit_type])
Bob Q.
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3811
by: Grant Hammond | last post by:
I assume I'm not alone in my frustration that the expression builder that comes (in part) with Access XP that dosnt wrap text when you open it on an exisitng expression in a query or form. I's bad enough that Microsoft dropped the expression builder from the VB window (which I have restored using Michael Kaplan addin), but I cant understand how they could not have fixed this obviously and annoying BUG!@
1
2537
by: Laertes | last post by:
Hi, I want to use the expression builder in a query to define a field. I know how to do it for simple fields, like the one below : orderdate: IIf((IsNull() And =False) Or (<>"N/A" And =False),,) When though the expression is too complex, the builder is not very convenient to use. I tried to use a function instead... The error I
3
2042
by: X_HOBBES | last post by:
I'm fairly new to Access, let alone Expression Builder. However, it seems that I'm either doing something really wrong or Access is really stupid! I can't reference fields that show up on my report! For example, if I have a field named MyField on my report, the Control Source has the value MyField, and it displays the values of MyField properly in the report. If I try to use an expression as simple as =, it fails! I get "# Error"...
2
7372
by: Mike Turco | last post by:
I like using the expression builder for a lot of different things but it isn't always available when I want to use it, for example in the code window, or in all of the control properties. I am usually stuck having to go into the database window, creating a new query, etc., and then right-clicking in a field and selecting build. Is there a shortcut key, a way to add a button to an Access toolbar, or something like that so I can use to...
1
1726
by: Don | last post by:
I'm trying to build a simple report. It will show debtors, budgeted amounts and how much was actually paid to those debtors. I've tried using the expression builder, though I've never used it before I somehow believe I know how, apparently not! I chose the location of where the data is stored and the expression builder put it into the expression builder window. When I run the report I get this #name?. I guess that means it doesn't...
0
2481
by: AlexanderTodorovic | last post by:
Hello Everyone, I'm developing a client application in which the users need an expression builder as provided in MS Access 2003. I would like to use the expression builder in a C# application. Is is possible to call the expression builder e.g. via automation? If yes, how can i execute the rules and get the result?
3
10371
by: rrosynek | last post by:
I have a 2003 Access Database with several tables related in a one to many relationship with a parent I am looking to build a report which evaluates if different users of the table have all entered data properly. As an example - the parent table creates the customer account number, customer last name and customer ssn. A related table creates all other customer information including address, phone etc., another related table contains...
18
4426
by: emajka21 | last post by:
Access 2000, I am trying to add a "Summed" total to a report (in a grouped footer section). But I only want to sum the top 3 items. I know how to write this in sql but it seems I can't get a to a sql expression box from the report view/text box. I can get to the text box properties but that only allows me to open up the expression builder. So is there a way to sum the top 3 in expression builder? Is there way to nest two different...
1
1237
by: hsullivan | last post by:
I have a rether simple, straight-forward Access database and need to include a calculated field in the report. My Access skills are elementary, ergo the need for assistance. I have a "Date_Received" field and an "Inventoried" field . I need assistance in building an expression in the calculated field something like this: IF INVENTORIED<>T THEN DATE() - DATE RECEIVED I can not figure out how to accomplish this. Help would be most...
0
9655
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.