473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

iif in Criteria field

Hi I'm trying to use an iif statement in the criteria field of a query.

FRON is just a flag either 0 or 1
MYS02 is a date

if FRON = 0 I want to return entries for MYS02
if FRON = 1 I want to return entries from MYS02

Expand|Select|Wrap|Line Numbers
  1. IIf([Forms]![FRMOPPMAIN]![FRON]=0,[Forms]![FRMOPPMAIN]![MYS02],>[Forms]![FRMOPPMAIN]![MYS02])
I have tried the options by themselves and they work fine I just cant get them to work in the iif.

Attached Images
File Type: jpg Untitled.jpg (31.1 KB, 384 views)
Nov 29 '11 #1
4 1527
Rabbit
12,516 Expert Mod 8TB
... Both conditions result in the same thing... Either way you get MYS02.
if FRON = 0 I want to return entries for MYS02
if FRON = 1 I want to return entries from MYS02
These two sentences mean exactly the same thing.
Nov 29 '11 #2
Dear Rabbit, look a bit closer.

If FRON=0 I want to return all entries FOR MYS02 (FOR a specific Date)
If FRON=1 I want to return all entries AFTER MYS02(FROM a specific Date)

The false part of the iif starts with > so dates greater than (or later than)

At least that's what I was expecting it to do.
Nov 29 '11 #3
Rabbit
12,516 Expert Mod 8TB
You didn't say after, you said from. From by itself means equals. If you wanted to say after, you should have said after. Or from ... onwards, but from onwards has a slightly different meaning than your intention.

FROM 1/1/2011 means = 1/1/2011
FROM 1/1/2011 ONWARDS means >= 1/1/2011
AFTER 1/1/2011 means > 1/1/2011

Back to your question. You can't use a comparison operator as part of your return value. Instead, use the BETWEEN method. And for the start date, return MYS02 if FRON is 0 and MYS02 + 1 otherwise. And the end date, return MYS02 if FRON is 0 and 12/31/9999 otherwise.
Nov 29 '11 #4
NeoPa
32,556 Expert Mod 16PB
You can't do it like that. You need to think it a little differently.

You haven't told us which field in your recordset you are filtering this way in your criteria (WHERE clause) so I will assume [DateFld] and you can change it to fit your one :

Expand|Select|Wrap|Line Numbers
  1. WHERE ([DateFld] = [Forms]![FRMOPPMAIN]![MYS02])
  2.    OR (([DateFld] > [Forms]![FRMOPPMAIN]![MYS02])
  3.   AND ([Forms]![FRMOPPMAIN]![FRON] = 1))
NB. Though technically your question was correct, it wasn't easy to see what you meant by that (For & From) due to how it was laid out. It may be worth considering that in future. Reading it now, I can understand what you were saying, but I only worked out how to interpret it after you pointed it out.
Nov 30 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: colmobrien | last post by:
Help Needed ms access 2000 I have a table where one field is the year end monthr (January, February,........, December) and another field is the year end day (1,2,3,........,31) i want to...
3
by: Peter Bailey | last post by:
Could someone please tell me how to pass criteria as if it were a parameter. I have a routine now that creates the sql string (well almost). at present the parameter is so I can pass one item ie...
1
by: John Baker | last post by:
Hi; Dumb question, but I have a query and i want to accept the record if a field is blank. I have tried criteria of ="", isempty(Fieldame) and a rich variety of other things with no joy. How do...
3
by: pelcovits | last post by:
I am trying to set up an unbound form to enter report criteria. I've followed the MS Office Assistance document: "Create a form to enter report criteria" which describes how to enter data (such...
2
by: x | last post by:
hi i have made a crosstab query in which row heading is "date", colum heading is "aircraft type" and the value to be summed up is "1-10 row totals". i want to create a simple query which should...
10
by: sesling | last post by:
I have created a query that will pull information from our database for the operators. This query will pull in on average 50,000 records. The operators need to refine the search results. I have...
1
by: kaosx5 | last post by:
I am running Access 2003. I would like to be able to search the criteria section in an Access query to see if it populated with anything. I have a report database that has a list box and some...
2
by: ziccardi | last post by:
When my query is executed it produces no results. However, if I copy and paste the criteria from the information populated and referenced in my query, it works fine. The criteria needs to be...
2
by: tomric | last post by:
I have a question on passing data to the criteria of a parameter of a parameter query using VBA. I have a query set up that has ten different fields in it. One is field named “status”, this field...
1
by: Natasha2401 | last post by:
If this was entered in the criteria field of an access database,what would it mean? !!
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.