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

Switch with Left function

Status
Not open for further replies.

Dausa67

Technical User
Oct 1, 2008
96
US
Good morning,
I have a text field in a query that contains 3 sets if data that I am trying to pull out. I have tried using the Switch function and the IIF but when I combine more than one statement it does not work.

I am using ACCESS 2003 and do not know VBA.

Below is not code but just a written statement of what I need to do:
if {TXNCD} = "12" then LEFT (ORDNUM}, 5) else
if {TXNCD} = "13" then LEFT (ORDNUM}, 5) else
if {TXNCD} = "41" then LEFT (ORDNUM}, 7)

I have tried the following code in the query:
Code:
IIf([TXNCD]="12" Or "13",Left([ORDNUM],5) Or IIf([TXNCD]="41",Left([ORDNUM],7))

Any Suggestions?

Clay

Clay
 
Hi,

Code:
IIf([TXNCD]="12" Or [TXNCD]="13",Left([ORDNUM],5),IIf([TXNCD]="41",Left([ORDNUM],7)))
 
Thank you Skip. That worked perfectly.

Clay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top