Code based on Query Value

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

Guest

I am a newbie trying to make a time saving change in a query that has been
setup for me. My Query lists attendance reasons which are one of 3:
Present
Excused Absence
Unexcused Absence

How can i get the query to show a
P (for present)
UN (for unexcused)
EX (for excused)

Thank You,
 
I am a newbie trying to make a time saving change in a query that has been
setup for me. My Query lists attendance reasons which are one of 3:
Present
Excused Absence
Unexcused Absence

How can i get the query to show a
P (for present)
UN (for unexcused)
EX (for excused)

Thank You,

Add a new column to the query.
WhyAbsent:IIf([Reason] = "Present","P",IIf([Reason] =
"Unexcused","UN","EX"))
 
You can add another field in the query, and use the switch function

NewFieldname: Switch([attendance reasons]="Present","P",[attendance
reasons]="Excused Absence","EX",[attendance reasons]="Unexcused Absence","UN")
 
If you want to settle for 2 characters (PR,UN,EX) then you can use a new
column in the query.

Field: AttendanceReason: UCase(Left([YourField],2))

Left extracts the two leftmost characters, UCase changes the characters to
upper case. Otherwise you will need to use the Switch function or some
nested IIFs.
 
Back
Top