473,395 Members | 1,996 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,395 software developers and data experts.

iif statement

Here is my situation:

I have a text box control. I want to check a field in my database and compare it to 0. The field is Car1 in the GARAGE table. If the value of Car1 is "0" the the text box control should display "NO" if not then "YES" The statement I have is as such:
Expand|Select|Wrap|Line Numbers
  1. =IIf([GARAGE]![Car1]=0,"NO","YES")
The control is on a report and when I run the report it prompts a paramater query on GARAGE. Leaving it blank and hitting OK generates the report but the textbox control displays #Type!

Am I messing up the syntax?
Nov 18 '11 #1
3 1869
NeoPa
32,556 Expert Mod 16PB
Controls on a form or report don't have direct access to the whole database. Only to the Record Source of the form/report.

What you can do though, is use a DLookup() call if you need to (Better would be to arrange the Record Source such that the required value is included if it makes sense to).

Expand|Select|Wrap|Line Numbers
  1. =Format(DLookup("[Car1]", "[GARAGE]"), "Yes;Yes;No")
NB. Your example only referenced the field in the table. It didn't indicate which record to use.
Nov 18 '11 #2
Thank you for your help.

The records to use will be based on a query or filter. (I haven't decided exactly how I'm going to develop this.) However, as the report stands, it includes all records.

I tried the DLookup() function and had this as a result on my report:

Car1: 364e0

The field in question is included in the Record Source.

[Car1] is a number data type field. It is used to store how many cars the first garage can hold. It may be left blank or contain a 0 in addition to the format of '##.#'.
I want to return a text string of "YES" if the value is greater than zero on that particular report I am working on. The report is a summary style report where I have dataset totals (Mean, Median, ect.)in the header section and the records used to calculate these totals in the detail section.

Hope that helps to identify the issue.

As always, thank you for all the help you provide to me and others!

Also,
If it would be a better choice I can add a field to the table. I know that would be easier. Would it be better on performance?
Nov 23 '11 #3
NeoPa
32,556 Expert Mod 16PB
Wisni1rr:
Expand|Select|Wrap|Line Numbers
  1. Car1: 364e0
Interesting. You also say the field is numeric, yet this indicates otherwise. The DLookup() code I provided (or technically the Format() code) would have converted any non-zero numeric value into the string "Yes" for you. It wouldn't have handled a Null though. For that you need :
Expand|Select|Wrap|Line Numbers
  1. =Format(Nz(DLookup("[Car1]", "[GARAGE]"), 0), "Yes;Yes;No")
Wisni1rr:
If it would be a better choice I can add a field to the table. I know that would be easier. Would it be better on performance?
There are various reasons why this would be a bad idea. None of them is related to performance though. For a better understanding of why see Database Normalisation and Table structures.
Nov 23 '11 #4

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

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.