Solved

And Operator in TruePart section of an IIf statement

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

758 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

19 Experts available now in Live!

Get 1:1 Help Now