thenoisydrum
Registered User.
- Local time
- Today, 14:55
- Joined
- Jul 26, 2012
- Messages
- 52
Hello,
I have found threads on similar issues but still cannot find a solution to my problem so here goes;
I have a query called Low Margin Transactions, that I guess speaks for itself.
I have a query based on this which selects the previous day's figures where the margin is below 8%. However on a Monday I would like the query to select Friday's, Saturday's and Sunday's low margin transactions. The query will run by a user so I don't want them to have to edit the query. I want it to be a simple click of a button for them.
As a starting point for the 3 previous days scenario, this actually works;
[Low Margin Transactions].[Day(D&T)]=Date()-1 Or [Low Margin Transactions].[Day(D&T)]=Date()-2 Or [Low Margin Transactions].[Day(D&T)]=Date()-3
If however I incorporate it into an IF statement it does not work;
IIf(Weekday(Date())=5, [Low Margin Transactions].[Day(D&T)]=Date()-1 Or [Low Margin Transactions].[Day(D&T)]=Date()-2 Or [Low Margin Transactions].[Day(D&T)]=Date()-3, Date()-1
I have the weekday = to 5 at the moment because today is Thursday, once I know the statement works it would obviously change to 1 for Monday.
Where am I going wrong with this? Both the true and the false statements work on their own.
I have found threads on similar issues but still cannot find a solution to my problem so here goes;
I have a query called Low Margin Transactions, that I guess speaks for itself.
I have a query based on this which selects the previous day's figures where the margin is below 8%. However on a Monday I would like the query to select Friday's, Saturday's and Sunday's low margin transactions. The query will run by a user so I don't want them to have to edit the query. I want it to be a simple click of a button for them.
As a starting point for the 3 previous days scenario, this actually works;
[Low Margin Transactions].[Day(D&T)]=Date()-1 Or [Low Margin Transactions].[Day(D&T)]=Date()-2 Or [Low Margin Transactions].[Day(D&T)]=Date()-3
If however I incorporate it into an IF statement it does not work;
IIf(Weekday(Date())=5, [Low Margin Transactions].[Day(D&T)]=Date()-1 Or [Low Margin Transactions].[Day(D&T)]=Date()-2 Or [Low Margin Transactions].[Day(D&T)]=Date()-3, Date()-1
I have the weekday = to 5 at the moment because today is Thursday, once I know the statement works it would obviously change to 1 for Monday.
Where am I going wrong with this? Both the true and the false statements work on their own.