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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf statement or If .. Else Query 1

Status
Not open for further replies.

darinmc

Technical User
Feb 27, 2005
171
GB
Hi
I have a query, in the one field, I have the below statement, however i need to make it more complex, like an if...else statement

Code:
Desc: [EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate"

I would like it to show:

ON ALL RECORDS
Desc: [EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate"

(EXCEPT) BUT if [clientRegNo]=1 then

Desc: [EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate - (" & [EmpPinNo] & ")"

OR USING IIf, something like:

Desc: IIf([clientRegNo]=1, "[EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate - (" & [EmpPinNo] & ")"", "[EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate"")


Hope u can help
Thx
Darin
 
I managed to get it to work using simiar code, I must have had comas or something wrong PLUS I had to change ClientRegNo to reflect [TESTjobs].[ClientRegNo]

Code:
Desc: IIf([TESTjobs].[clientRegNo]=1,[EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate - (" & [EmpPinNo] & ")",[EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate")

Thx Anyway
Darin
 
A simpler way:
Code:
Desc: [EmpForename] & " " & [EmpSurname] & " - " & "Basic Rate" & IIf([TESTjobs].[clientRegNo]=1," - (" & [EmpPinNo] & ")","")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top