473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 12090
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,IIf([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.edu> wrote in message
news:66**************************@posting.google.c om...
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.google. 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",IIf([STAGE]>300,"01","")))

Xiaolu
Nov 12 '05 #3
fe*@buffalo.edu (Fran Zablocki) wrote in
news:66**************************@posting.google.c om:
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 cvtStage2Appstatus. I usually have a module
Conversions with several of these functions. They will even appear
in the expression builder. Very handy.

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

select case mystage
case >=600
cvtStage2Appstatus = 03 ' or "03"
case > 300
select case myAdmit_type
case "AF"
cvtStage2Appstatus = 02 ' or "02"
case "AFD"
cvtStage2Appstatus = 02
case "AP"
cvtStage2Appstatus = 02
case "APD"
cvtStage2Appstatus = 02
case else
cvtStage2Appstatus = 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
cvtStage2Appstatus = 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: cvtStage2Appstatus([Stage],[Admit_type])

Or in a textbox.controlsource on a form or report
=cvtStage2Appstatus([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
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...
1
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...
3
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...
2
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...
1
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...
0
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....
3
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...
18
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
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...

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.