Query statement

paul29berks

Active Member
Joined
Mar 15, 2004
Messages
293
I have written the statement below:

IIF([type]=*B and [startdate]>Date(), "X", "Y")

My results however return all types with a start date > todays date with X and not restricted to those like B.

Can anyone suggest something in my statement I have missed?

Thanks
 
Many thanks

There are definately types ending with b and no other statements excluding b.

My full SQL for the query is below.

SELECT Missing_Client_Codes_Ext.organisationCode, Missing_Client_Codes_Ext.organisationClientAccount, Missing_Client_Codes_Ext.organisationName, Missing_Client_Codes_Ext.Year, Missing_Client_Codes_Ext.Month, Missing_Client_Codes_Ext.organisationRef, Missing_Client_Codes_Ext.Address, Missing_Client_Codes_Ext.Add2, Missing_Client_Codes_Ext.Add3, Missing_Client_Codes_Ext.invoiceStatus, Missing_Client_Codes_Ext.Contact, Missing_Client_Codes_Ext.eventRef, Missing_Client_Codes_Ext.Division, IIf([dbo_vwPlacementSheets].[contact1Fax]="",[dbo_vwPlacementSheets].[contact2Fax],0) AS ContactFax, ([dbo_vwPlacementSheets].[contact1Tel]) AS ContactTel, ([dbo_vwPlacementSheets].[contact1position]) AS ContactTitle, Missing_Client_Codes_Ext.[Organisation Character Count], IIf([type] Like "*B",IIf([startdate]>Date(),"EBNIBKOT","BACKOUT"),"") AS Backouts, Missing_Client_Codes_Ext.type, Missing_Client_Codes_Ext.startDate
FROM Missing_Client_Codes_Ext
WHERE (((Missing_Client_Codes_Ext.Year)=[Forms]![Interface]![Year]) AND ((Missing_Client_Codes_Ext.Month)=[Forms]![Interface]![month]));

many thanks
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi Paul

I can't see anything wrong with the SQL (but would be happy to be proved wrong by others!).

Per my previous post did you try changing the "" part to "Z" - and if so, did you see all Z's?

If you change this part
[type] Like "*B"
to this
Right([type],1)="b"
does that make any difference?

Andrew
 
Upvote 0
*The penny dropped*

Are there trailing spaces on the type field? If so try using :
Right(Trim([type]),1)="b"
or
Trim([type]) Like "*B"

HTH, Andrew
 
Upvote 0
This worked for me...

Backouts:IIf([type] Like "*b",IIf([startdate]>Date(),"X","Y"),"Y")

Query...
Book1
ABCD
1TypeStartDateBackouts
2comb22-Sep-06Y
3bomb01-Oct-06X
4camera01-Sep-06Y
5halo27-Sep-06Y
Sheet5


Denis
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top