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

Union query would not work

Status
Not open for further replies.

teqtaq

Technical User
Nov 18, 2007
197
US
Please, help with this problem.
I had inherrited a query.

IIf([reg/temp]="R","Regular",IIf([tbl_1]![Grade]="IC","Ind Contractor",IIf([reg]="t",IIf([long descr]="RH","Contract",
IIf([reg]="t",IIf([long descr]="PT" And [tbl_1]![TYPE]<>"Home","Temp","Don't Know"))))))
_______________________________________________

It gets in union with another query

IIf([tbl_1]![type] Is Null,"Office",IIf([TBL]!
Code:
="Office","Office",IIf([tbl_1]![code]="Home","Home or Client",
IIf([tbl_1]![code]="Client","Home or Client","don't know"))))


When executed - I need to have 5 columns with names
Regular
Contract
Home or Client
Temp
Ind Contractor

I am assuming because of these queries are not in sync column-wise - wrong numbers getting into wrong columns.
When I am trying to re-arrange order of the columns it tells me - wrong number of arguments.

Please, help me to get the result as it has to be 5 columns in order I had put.
If possible, please.

Thanks,T
 
These are conditions, not queries.
There is no UNION ALL conditions.

You either use AND or OR statements to combine conditions.

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
I know it is made into Union already.
But results are weird.
So I went and checked one by one and I saw columns are not lined up as suppose to.

I had tried to re-arrange it and can't go through witht his because of the syntax issues.
 
I am trying to work witht the first one. I had changed it to
OK, if I change it like this should it work you think?
IIf([reg/temp]="R","Regular",IIf([reg]="t",IIf([long descr]="RH","Contract",IIf([reg]="t",IIf([long descr]="PT" And [tbl_1]![TYPE]<>"Home","Temp","Don't Know",IIf([tbl_1]![Grade]="IC","Ind Contractor"))))))

And it says 'wrong number of arguments'. But I had not taked any out - I just re-arranged them.
 
I just re-arranged them
Without even knowing the syntax of the IIf function ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
could you switch to the SQL view of the query and post it in its entirety instead of just this little snippet that doesn't really help us much.....

Leslie

In an open world there's no need for windows and gates
 
It works now!

Status: IIf([reg]="R","Regular",IIf([reg]="t",IIf([long descr]="RH","Contract",IIf([reg/temp]="t",IIf([long descr]="PT" And [tbl_1]![TYPE]<>"Home","Temp",","Don't Know",IIf([ACT_BON]![Grade]="IC","Ind Contractor"))))))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top