How To Write Iif Statement Which Has Two True Cases

Aug 12, 2007

Hi, the syntax is of iif is that iif(case, true, false) right.
In my case I have role_ID to filter so my iif statement is something like
iif([role id] = "1", "2" or "3")
But it does not work, I don't know why
iif([role id] = "1", "2")
It works. So I think OR statement is something wrong.What should I do in this case?

View Replies


ADVERTISEMENT

Queries :: IIF Statement With And In True Statement

Oct 31, 2014

I have a query with the following criteria in one of the fields:

>=DateAdd("m",-12,fom()) And <=DateAdd("m",1,fom())

fom is a function for first of the current month. I need this query to be specific to what month it is when its ran so i want to only have this criteria if the month is > = october. If it isnt October or greater, i want the criteria to reflect this.

>=DateAdd("m",-12,fom()) And <=fom()

Which also works by itself. But when i add it to an iif statement it always produces no results. Below is the iif statement.

Iif(month(date())>=10, >=DateAdd("m",-12,fom()) And <=DateAdd("m",1,fom()),>=DateAdd("m",-12,fom()) And <=fom())

I have also added the column name to each expression and it still doesnt produce any results.

View 4 Replies View Related

Is It Possible To Return No Value When An If Statement Is True?

Sep 22, 2006

This should be really simple, but I am stumbling on the criteria. I have a combo box which returns "Y" or "N". I'm using this value as criteria for a field called [Planned=Y/N]. This field stores either a "Y" or a "N" to indicate that a network outage was planned or not. If the combo box is "Y" I want to return all values(Y and N). If the combo box is "N" I only want to return values of "N". I've tried the following in the criteria without the desired affect:

IIf([Forms]![frmOutagemenu]![cboflag]="Y","","N") - only returns records when "N" is selected.

IIf([Forms]![frmOutagemenu]![cboflag]="Y",null,"N") - only returns records when "N" is selected.

IIf([Forms]![frmOutagemenu]![cboflag]="Y",In("Y","N"),"N") - too complicated for Access to decode.

Is there another way to return nothing for the criteria when "Y" is selected?

View 3 Replies View Related

How To Write One Sql Statement Into Another

Apr 18, 2007

I am new to using sql statement in my codes. I need help in writing a sql statement using one sql statement (sql_1) in another (sql_2)? In the sql statements below, I am trying to replace "query2" with the sql statement (sql 1). Please help

sql 1: SELECT tbl_HourTypeMaping.CustomerCode_HTMP, tbl_HourTypeMaping.HourTypeCode
FROM tbl_HourTypeMaping
WHERE (((tbl_HourTypeMaping.CustomerCode_HTMP)="htmp_default"));

sql 2: INSERT INTO tbl_HourTypeMaping ( CustomerCode_HTMP, HourTypeCode )
SELECT Query2.CustomerCode_HTMP, tbl_HourType.HourTypeCode
FROM tbl_HourType LEFT JOIN Query2 ON tbl_HourType.HourTypeCode = Query2.HourTypeCode
WHERE (((Query2.CustomerCode_HTMP) Is Null));

View 2 Replies View Related

Queries :: IIF Statement With Two True Values

Dec 3, 2014

Can I generate an IIf statement with two-true values? I have these two statements but don't know how to combine them:

IIf((Weekday(date);1)=vbMonday or vbTuesday or vbWednesday or vbThursday or vbFriday;x;””)
IIf((Weekday(date);1)=vbSaturday or vbSunday;y;””)

I have at field with a date and will like the true statement to be “x” if the data is Monday-Friday and “y” if the date are a Saturday or Sunday and if the date field is blank, I want to have a blank field here as well.

I have tried:

IIf((Weekday(date);1)=vbMonday or vbTuesday or vbWednesday or vbThursday or vbFriday;x;y)

But it returns y in fields that should be blank.

View 7 Replies View Related

IIF Statement Returning Same Result For True And False?

Jan 10, 2012

I've built an IFF expression that is determined by a number of variables.

If any of the Data fields are filled I want the statement to return true.

If NONE of the four are filled in I want it to return false.

As it is, it returns true no matter what.

Here is the expression I'm using:

Title: IIF (IsNull([Data1] and [Data2] and [Data3] and [Data4]), True , False)

View 7 Replies View Related

Forms :: How To Write Insert Statement

Jul 31, 2014

The row source for the combo-box is

SELECT tbl_p.P_ID, [plast] & " , " & [pFirst] AS Expr1 FROM tbl_p ORDER BY [plast] & " , " & [pFirst];

If notinlist I would like to add the the new name, how should I write the INSERT Statement?

View 1 Replies View Related

Modules & VBA :: If Statement Not Return True Based On Data

Mar 14, 2014

I have a complex IF Statement within VBA. When I step thru the code the if statement variables should return true but instead treats it as False. See '>>>> this happens on the 2nd Pass of a Do Loop Statement, the First Loop the if Statement Returns True

Variable Values:

Record 1
contractNo: 00001634
nfld: 33.40%
nTier6: 30.00%

Record 2
contractNo: 00001634
nfld: 137.52%
nTier6: 28.50%

so the 2nd if should be true but it acts as false an moves to next If statement.

Code:

If nfld = Format(0, "Percent") Then
nOvrAmt = 0
BkOvrCalc = nOvrAmt
GoTo cont:
'>>> ElseIf nfld > nTier6 Then
nOvrAmt = rs.Fields("TotalNetUSExp") * rs1.Fields("T6E").Value

[Code] .....

View 1 Replies View Related

General :: Determine Value Of Any Field Based On True And False Statement

Aug 5, 2013

In a form, the value of any field may determine if the other field will be true or false. For example in my form, inventory, if value in code is equal to 2 then the Field Table will be automatically false.

View 12 Replies View Related

Queries :: IIF Statement With Comparison Operators In True And False Parts

Oct 2, 2014

I have a report where my customer wants to be able to input a value and then be able to select whether the report shows values above or below that value. I have a combo box that has 2 values (1=Less than or equal to, 2=greater than or equal to). There is a text box where he inputs the rate to compare against (e.g. $75). When he hits submit, the application stores the values of the combo box and text box into global variable and then I have a public function that can be used to retrieve the values. GetHRate() gets the value to compare against and GetHRateCompare() gets the value to indicate <=(1) or >=(2).

In my query for criteria for rate I have this expression:
IIf(GetHRateCompare()=1,"'<=",">=") & GetHrate()

I've tried every combination of double quotes, single quotes, no quotes moving the GetHRate inside the IIf statement and nothing seems to work.

If I just hardcode <=GetHrate() into the criteria it works perfect but that does not achieve my goal of letting him select over/under at run time. Here's the full query:

SELECT qryCustomers_AverageTimeByScheduleID.ServiceName, qryCustomers_AverageTimeByScheduleID.ScheduleID, qryCustomers_AverageTimeByScheduleID.SumOfTotalTim e, qryCustomers_AverageTimeByScheduleID.PropertyID, qryCustomers_AverageTimeByScheduleID.PropertyName, qryCustomers_AverageTimeByScheduleID.MonthCount, qryCustomers_AverageTimeByScheduleID.AverageTime,

[Code] ....

View 2 Replies View Related

Queries :: Multiple Query Criteria IIF Statement - True Condition

Feb 24, 2015

I'm trying to have a single or multiple query criteria based on what the user checks on a form.

I can't get the True condition to work at all, I get no records. Here is what I'm using

IIf([Forms]![FrmAttendanceLogsRpt]![BlkFilter]=-1,[TempVars]![EID] Or 86,[TempVars]![EID])

If I just put
[TempVars]![EID] Or 86
in the Criteria it works just fine.

View 14 Replies View Related

Appending Leading Zeros By If Statement With Formulas For True And False In SQL

Jul 15, 2014

My first question is how do I append 00001 so I can have a value for the false side of 9123400001 instead of 912341...My second question is why does it prompt me to enter parameters? It also produces all false values from the if statement...What I am trying to do is use a column that has either a Y or a N and using the if statement to correspond with different formulas depending on the Y or N.This what I have so far.

SELECT
IIF (ISRAILROAD=Y,9 & UCN & TXRTAREA, 9 & UCN & 00001 )
FROM CombinedUtility;

View 5 Replies View Related

Cases Take Time

Sep 13, 2005

Same database as all my other questions, but this time the request is that each case has a duration field.
Is there an easy way to have a single query give a count of how many cases were considered light, medium or heavy given that light is a duration of 0-2 hours, medium is 3-5 hours and heavy is 6+.
The only thing I could think of was to have a query for light, medium and heavy to do the counts for me. But I was curious if there's a way to have one query do it.

View 4 Replies View Related

Cases Open On Given Day

Feb 22, 2006

I have tried and tried to figure this out, with no luck. So I'm asking for someones help.

I'm trying to find the CASE_ID for all cases which were open (case status O) on 12/31/2005 in the sample DB attached. There are only two tables to work with.

Thanks

Mike

View 2 Replies View Related

Multiple Cases

Jul 10, 2007

Hello,
Say for example, I would like to run a query that would search through a table with each person's deposit amount, assign band 1 if they have deposit less than 1 million, band 2 if 1-2 million and band 3 if more than 2 million. How can I:
1. Add in the extra column in the table?
2. Assign the bands since I can not use iif here as their are 3 cases?

Thanks!

Regards,
anyi

View 1 Replies View Related

Counting Of Cases And Counting No Records

Jan 26, 2007

I have a report due the first of each week in which I need the cases open and cases closed for the previous week, the week two weeks prior and the 2007 and 2006 year to date on two different types of cases. I have a case management table with a field for Type of Case, date assigned and date closed that I uses in my queries. Presently I have two query, one that generates only Type 1 cases from the Case Management Table and another for Type 2. I then use the Type 1 Query in another query that limits the results for Type 1 cases to those opened last week, one for those open two weeks ago, one for 2006 YTD and one for 2007 YTD. In these 4 queries I have one field [Type of Cases] and I have the query count. I then do this for Type 2 cases and then go through the whole process to do Closed Cases. All my queries have criteria to automatically filter the dates to the time periods mentioned above. I then have one report query that I put all the number in for my report. This query has 16 fields with the numbers for each period, last week open and closed, 2 weeks open and closed, etc. I then generated a report that takes these numbers from my report query and puts it in a report format automatically. As you can imagine this takes some time to go through each query to generate these numbers, so I was wondering how I may do this differently. Also, I have experienced a problem when a field produces no records I get a blank sceen with nothing under the Count of column and get the same thing for my report. How can I fix this.

View 1 Replies View Related

Queries :: Update Statement For A OUTER JOIN Select Statement

Feb 12, 2014

I have the following Select Statement:

SELECTTenant.ID, Tenant.[First Name], Tenant.[Last Name], Tenant.Address, Tenant.City, Tenant.State, Tenant.Zip, Tenant.[Home Phone], Tenant.[Cell Phone], Tenant.[Work Phone], Tenant.[Rented Unit],
Tenant.[Security Deposit], Tenant.[Move In], Tenant.[Move Out], Tenant.TenantID, Tenant.UnitID, Tenant.PropertyID, Tenant.OwnerID, Owner.Company, Owner.ID AS Expr1, Property.[Property Address],

[code]....

Now, I know that something in the UPDATE statement does not match my select statement.What should my Update Statement be, in order to update all the columns in the joined tables?

View 2 Replies View Related

If A Is True, Then Do B

Apr 9, 2007

=IIf([Text34]<=2644,0,IIf([Text34]<=7164,650,IIf([Text34]>=242506,22000,[Text34]*0.0907194)))

The above formula works as is in the field I have it in, but need it performed only if [Label5] is marked yes. I guess what I need is what goes in front of the above formula. I've looked through the forum, but it is so huge I had no luck finding what I needed.

If [Label5] is no, I need it to go to [Label6] and if [Label6] is yes, perform another calc like the one above. If [Lable6] is no, I need an error message.

Hope this is clear. Any help is greatly appreciated.

Thanks.

View 3 Replies View Related

Allowaddition = True

Sep 15, 2005

Hi all very simple question i'm sure but had a look through the forums and couldn't find anything.

On a form i have 2 buttons, one for new data and one for editing data. When either of these buttons are clicked a few text boxes pop up and immediately display data (The first record of the recordset). For the edit button this fine, however how do i get the text boxes to display a new record and not allow the user to head backwards through the recordset only onto a new record??

Thanks in advance

View 4 Replies View Related

Posting A Pic When A Value = True

Jan 31, 2008

Hi everyone,

I have made a form for our database and I would like to have a .gif image display when a certain checkbox is checked. Any idea how to do this?

Thanks

PS - sorry if this is a noob question...I don't use access much

View 4 Replies View Related

Locked=True Fuzzy

Jun 1, 2005

I have a form that has code tied to the 'on open' event that is going to be accessed by users where we want them to only have access to certain fields which we want them to fill out. The fileds that will be locked will change based on the field called 'Item Number'. The code will be long because there are 30 different Item Numbers and about 10 to 20 fields that we will disable based on the Item Number. The code is like:

Dim Item_Number As String
If Me.Item_Number = "32000" Then
Me.Batch_Lot_Number.Enabled = False
End If

This is all great except that the disable makes the field kind of obscure by the color it gives it. I don't want to use the lock property because that doesn't give you a visual clue that its locked.

Is there a way to change the color of the field background using VBA?

View 5 Replies View Related

Iif With True Part Containing 2 Values

Nov 28, 2005

First Post - please be gentle :)

I may be missing something here, but can any one help?

I am using a Iif statment in a query to filter records as follows:

If([value from a form]= "all holidays",("weeks hols" or "days hols"),"not a holiday")

This is returning a to complex to calculate error - I think it is a Syntax error but could be wrong
but if I enter The string "week hols" or "days Hol" as the criteria without the Iif statment that works fine.

Thanks Dean

View 5 Replies View Related

Counting True Items

May 4, 2006

Can anyone help?
I have a table with the following:
Booked with a y/n field
Person Name with a text field
So...
Yes(True) Jim
Yes(True) Jim
No(False) Jim

What I need is to be able to show a query that shows if the checkbox is ticked (True) and the Name is Jim total up how many true items there are. So from the above I can see that Jim has 2 true items. I would then like this shown in a text box is this possible?
Also, it is not always going to be a person called Jim so... (From above)
Yes(True) Jim
Yes(True) Jim
No(False) Jim
Yes(True) Jack

So how would this go on a query in a sub form? So Name Jim would show 2 and Jack would show 1? At the moment is is grouping the name and I dont want that.
Any ideas
Cheers

View 4 Replies View Related

True Date Ranges

Nov 6, 2006

I run various queries on a daily basis for multiple date ranges (previous day, week to date, month to date, and year to date). The below criteria allows me to get WTD numbers but it has a flaw. When I run the reports on Monday, this criteria gives me Sunday and Monday's data when I actually want the previous week's data. Does anyone know of an iif statement that basically, says, "If today is Monday, give me last week's data, else give me wtd of the current week?" Right now, I manually change the criteria on Monday morning to hard code the dates and then revert to the formula on Tuesdays but I need to have this completly automated because there are a large number of queries and I don't have time to change them all. Thanks for the help!


Between Date()-Weekday(Date()-1) And Date()-1

View 2 Replies View Related

Count Of TRUE Statements?

Oct 18, 2006

Hi! When it rains, it pours, right? I'm wondering if any of you know of a way to count true statements...

What I mean is, I have a query where I have a series of 5 different OR statements, meaning I want to see records with either a min. ed. number, or a years of experience number, etc...

The query returns every record with at least one of the criteria being met. What I need is to count the statements that are true for one record. Let's say I have someone who meets all of the OR criteria, I need a way to count the number of criteria that they met. Is there a way to do this? Maybe with a crosstab query??? Thanks!!

KellyJo

View 3 Replies View Related

Open Query If Field Is True

Jun 6, 2006

I have 3 queries that pull from 3 dfferent tables. All 3 tables contain a field called Acct but the other fields in the 3 tables are different. What I would like is to have a form field that the user can input an account number and depending on which query the account number is in, that query and result will display. I have been trying the dlookup function but can't seem to get the coding down. Also, if the account number is not in any query I would like a message box to display saying it can't be found. Thanks for any help!

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved