stuwallace
New member
- Local time
- Today, 17:54
- Joined
- May 22, 2009
- Messages
- 7
I'm getting this error message when running my query. I'm a newbie so can't quite work out what I'm doing wrong. The query is below but I think the offending part of it is the true expression in the IIf statement and in particular the Instr function. If I put a static expression in there it works.
SELECT dbo_DT_CONTRACTOR.Account_No, dbo_DT_CONTRACTOR.Contractor_Name, dbo_DT_CONTRACTOR.Address_Line1, dbo_DT_CONTRACTOR.Address_Line2, dbo_DT_CONTRACTOR.Address_Line3, dbo_DT_CONTRACTOR.Address_Line4, dbo_DT_CONTRACTOR.Address_Line5, dbo_DT_CONTRACTOR.Post_Code, [Movex Customers].OKSMCD
FROM dbo_DT_CONTRACTOR INNER JOIN [Movex Customers] ON dbo_DT_CONTRACTOR.Account_No=[Movex Customers].OKCUNO
WHERE (IIf (6 = 1 ,[dbo_DT_CONTRACTOR].[Post_Code],Left([dbo_DT_CONTRACTOR].[Post_Code],InStr(1,[dbo_DT_CONTRACTOR].[Post_Code],' ')+1))) In (SELECT Postcode FROM Postcodes);
Any help would be much appreciated.
Stuart Wallace
SELECT dbo_DT_CONTRACTOR.Account_No, dbo_DT_CONTRACTOR.Contractor_Name, dbo_DT_CONTRACTOR.Address_Line1, dbo_DT_CONTRACTOR.Address_Line2, dbo_DT_CONTRACTOR.Address_Line3, dbo_DT_CONTRACTOR.Address_Line4, dbo_DT_CONTRACTOR.Address_Line5, dbo_DT_CONTRACTOR.Post_Code, [Movex Customers].OKSMCD
FROM dbo_DT_CONTRACTOR INNER JOIN [Movex Customers] ON dbo_DT_CONTRACTOR.Account_No=[Movex Customers].OKCUNO
WHERE (IIf (6 = 1 ,[dbo_DT_CONTRACTOR].[Post_Code],Left([dbo_DT_CONTRACTOR].[Post_Code],InStr(1,[dbo_DT_CONTRACTOR].[Post_Code],' ')+1))) In (SELECT Postcode FROM Postcodes);
Any help would be much appreciated.
Stuart Wallace
Last edited: