Solved

And Operator in TruePart section of an IIf statement

Posted on 2010-09-13
3
484 Views
Last Modified: 2012-05-10
Dear Experts,

I'm currently trying to figure out how to produce a query in MS Access that says "if today is Monday then look for data within a 24hr period, 4 days in the future"

The query that I've been working on appears to work when sperated down but not as a whole.  After much searching I found this might be because it is not possible to use the 'AND' operator in the TruePart of an IIf statement.

Does anybody know of a way round this?  I'm no expert in MS Access so the simpler the better!

Current Query:

iif(WeekDay(date())=2,>Format(Date()+4,"yyyymmdd") & "0000" And <Format(Date()+4,"yyyymmdd") & "2400","")

Thanks in anticipation,

Neil
0
Comment
Question by:qvhit
3 Comments
 
LVL 11

Expert Comment

by:Runrigger
ID: 33660575
can you include the full query please
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 33660611
you need 2 conditions, not 1, for example
> iif(WeekDay(date())=2, Format(Date()+4,"yyyymmdd") & "0000" )
< iif(WeekDay(date())=2, Format(Date()+4,"yyyymmdd") & "2400" )

Open in new window

0
 

Author Comment

by:qvhit
ID: 33660677
Thank you angelIII, sometimes it's just that simple!

I changed

iif(WeekDay(date())=2,>Format(Date()+4,"yyyymmdd") & "0000" And <Format(Date()+4,"yyyymmdd") & "2400","")

to become

>IIf(Weekday(Date())=2,Format(Date()+4,"yyyymmdd") & "0000") And <IIf(Weekday(Date())=2,Format(Date()+4,"yyyymmdd") & "2400")

and now it works!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
access pop-up form 3 30
Server configuration for MS Access - SQL Server app 8 68
Documents and settings folder 30 75
Access Open Report with SQL Parameter 11 28
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now