Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple IIf statements 1

Status
Not open for further replies.

Tronsliver

Technical User
Sep 19, 2000
120
US
I'm trying to insert multiple IIf statements in a query but keep getting an error message. I'm in query design mode and trying to insert the expression in the "field" slot. Here is an example:

mileducation: IIf([sidstrHI_MIL_COL_CR_COMPL]="A1","2"," "),IIf([sidstrHI_MIL_COL_CR_COMPL]="A0","1"," ")

When I try to save it I get a syntext error.

Thank you for the help,

Roger
 
Here are some corrections.

mileducation: IIf([sidstrHI_MIL_COL_CR_COMPL]="A1","2",IIf([sidstrHI_MIL_COL_CR_COMPL]="A0","1"," "))

This equates to

If [sidstrHI_MIL_COL_CR_COMPL]="A1" Then
mileducation = "2"
ElseIf [sidstrHI_MIL_COL_CR_COMPL]="A0" Then
mileducation = "1"
Else
mileducation = " "
End If Terry

;-) The single biggest challenge to learning SQL programming is unlearning procedural programming. -Joe Celko

SQL Article links:
 
You might be able to use the switch function here. Check the examples in help. How many possible values are there for this field and do you want to explicitly handle only the two values you've shown here? If so, it will probably do the trick.

Also: Do you want to insert a zero-length string or a single space? (it looks like the latter but that could be the web page)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top