function returns one value if..

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would i write a function that would return one value if field CLASS is
"A" and another if it is "B"
 
If there are only the two possible values then use --
IIF([CLASS]="A", 55, 44)

If there are more than those two possibilities then maybe use this --
IIF([CLASS]="A", 55, IIF([CLASS]="B", 44, Null), "Error")
 
How would i write a function that would return one value if field CLASS is
"A" and another if it is "B"

In a query?
Is the value to be returned a Text value?
Is there a possibility that the Class will be something other than "A"
or "B"?
Exp:IIf([Class] = "A","One Text Value",IIf([Class] = "B","Another Text
Value","Neither A nor B"))
 
I'm sorry, I did not make myself clear.
I want the query to look up the value from another table.
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
If CLASS in table NAMES is "B", I want to return a value from table CLASSES
field B

KARL DEWEY said:
If there are only the two possible values then use --
IIF([CLASS]="A", 55, 44)

If there are more than those two possibilities then maybe use this --
IIF([CLASS]="A", 55, IIF([CLASS]="B", 44, Null), "Error")

f2rox said:
How would i write a function that would return one value if field CLASS is
"A" and another if it is "B"
 
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
How is it to know which record in the CLASSES table?

f2rox said:
I'm sorry, I did not make myself clear.
I want the query to look up the value from another table.
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
If CLASS in table NAMES is "B", I want to return a value from table CLASSES
field B

KARL DEWEY said:
If there are only the two possible values then use --
IIF([CLASS]="A", 55, 44)

If there are more than those two possibilities then maybe use this --
IIF([CLASS]="A", 55, IIF([CLASS]="B", 44, Null), "Error")

f2rox said:
How would i write a function that would return one value if field CLASS is
"A" and another if it is "B"
 
There is a field in table CLASSES called CLASSNUM and a field in table NAMES
called CLASSNUM. So the query pulls values from the corresponding record in
CLASSES table

KARL DEWEY said:
field A
How is it to know which record in the CLASSES table?

f2rox said:
I'm sorry, I did not make myself clear.
I want the query to look up the value from another table.
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
If CLASS in table NAMES is "B", I want to return a value from table CLASSES
field B

KARL DEWEY said:
If there are only the two possible values then use --
IIF([CLASS]="A", 55, 44)

If there are more than those two possibilities then maybe use this --
IIF([CLASS]="A", 55, IIF([CLASS]="B", 44, Null), "Error")

:

How would i write a function that would return one value if field CLASS is
"A" and another if it is "B"
 
Post the table structure and sample data.

f2rox said:
There is a field in table CLASSES called CLASSNUM and a field in table NAMES
called CLASSNUM. So the query pulls values from the corresponding record in
CLASSES table

KARL DEWEY said:
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
How is it to know which record in the CLASSES table?

f2rox said:
I'm sorry, I did not make myself clear.
I want the query to look up the value from another table.
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
If CLASS in table NAMES is "B", I want to return a value from table CLASSES
field B

:

If there are only the two possible values then use --
IIF([CLASS]="A", 55, 44)

If there are more than those two possibilities then maybe use this --
IIF([CLASS]="A", 55, IIF([CLASS]="B", 44, Null), "Error")

:

How would i write a function that would return one value if field CLASS is
"A" and another if it is "B"
 
This is a simplified version:
CLASSES TABLE:
ID CLASSNUM START END A B
1 2611 7/20 10/11 086191 086192
2 2612 7/22 11/1 086217 086219

NAMES TABLE:
ID NAME CLASS CLASSNUM START END STATENUM
1 Student1 A 2611 7/20 10/11
2 Student2 A 2612 7/22 11/1
3 Student3 A 2612 7/22 11/1
4 Student4 B 2612 7/22 11/1

(Field NAME, CLASS, and CLASSNUM are entered. Fields START and END pull
information from table CLASSES. I would like field STATENUM to show the A or
B number depending on what class the student is in, and depending whether he
is in the A or B class.)

KARL DEWEY said:
Post the table structure and sample data.

f2rox said:
There is a field in table CLASSES called CLASSNUM and a field in table NAMES
called CLASSNUM. So the query pulls values from the corresponding record in
CLASSES table

KARL DEWEY said:
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
How is it to know which record in the CLASSES table?

:

I'm sorry, I did not make myself clear.
I want the query to look up the value from another table.
If CLASS in table NAMES is "A", I want to return a value from table CLASSES
field A
If CLASS in table NAMES is "B", I want to return a value from table CLASSES
field B

:

If there are only the two possible values then use --
IIF([CLASS]="A", 55, 44)

If there are more than those two possibilities then maybe use this --
IIF([CLASS]="A", 55, IIF([CLASS]="B", 44, Null), "Error")

:

How would i write a function that would return one value if field CLASS is
"A" and another if it is "B"
 
Back
Top