Solved

And Operator in TruePart section of an IIf statement

Posted on 2010-09-13
3
486 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 143

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

828 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