PC Review


Reply
Thread Tools Rate Thread

Access 2000 IIF statement

 
 
GMC
Guest
Posts: n/a
 
      18th Jul 2007
Hello all,

I am having problems trying to figure out how to write a statement that only
shows a column if there is something in the column. Right now I get a bunch
of blank records and then the one record with the stuff in it that I need.
I have a report that works off a query. The query works off a table and has
a field in it called "other_new_specify" and one with
"other_pending_specify". What I want to do is have the field show up on the
report only when there is something populating it those two fields.

The following statement gives me errors

Iif(IsNull(other_pending_specify]="" ""[other_pending_specify])

Any suggestions?

Thanks


 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2FyZW5G?=
Guest
Posts: n/a
 
      18th Jul 2007
Hi GMC,

Am I right in thinking that you need to set the criteria in a query to show
only records that are populated for the two fields you've mentioned? Have
you added the fields to your query grid? If so, then have you tried asking
for Not Null in the critera line?

The IIF statement you're writing appears to be incomplete. It is my
understanding that usually you would use the IIF in a query to generate data
in a new column, rather than to set criteria. If you are using the IIF in a
new column to generate data, and I have misinterpreted your example, please
forgive me. In this case, you will need to include your condition, true
value and false value, so, in a new column in your query grid, it looks like
this:

New column name:=IIF(your condition ie what you are comparing, what to do if
the condition is found to be true, what to do if the condition is found to be
false)

The separating commas are important as they show Access firstly what you are
looking for (often known as the condition or logical test), then after the
first comma, what to do if it finds it, and after the second column, what to
do if it doesn't. The colon between the new column name and the IIF just
tells Access where the new column name ends and the formula begins.

I hope this helps and hasn't confused you. Let me know how you get on.

Good luck,

Karen

"GMC" wrote:

> Hello all,
>
> I am having problems trying to figure out how to write a statement that only
> shows a column if there is something in the column. Right now I get a bunch
> of blank records and then the one record with the stuff in it that I need.
> I have a report that works off a query. The query works off a table and has
> a field in it called "other_new_specify" and one with
> "other_pending_specify". What I want to do is have the field show up on the
> report only when there is something populating it those two fields.
>
> The following statement gives me errors
>
> Iif(IsNull(other_pending_specify]="" ""[other_pending_specify])
>
> Any suggestions?
>
> Thanks
>
>
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      18th Jul 2007
On Wed, 18 Jul 2007 15:37:12 -0500, "GMC" <(E-Mail Removed)>
wrote:

>Hello all,
>
>I am having problems trying to figure out how to write a statement that only
>shows a column if there is something in the column. Right now I get a bunch
>of blank records and then the one record with the stuff in it that I need.
>I have a report that works off a query. The query works off a table and has
>a field in it called "other_new_specify" and one with
>"other_pending_specify". What I want to do is have the field show up on the
>report only when there is something populating it those two fields.
>
>The following statement gives me errors
>
>Iif(IsNull(other_pending_specify]="" ""[other_pending_specify])


Well, yes, that would error all over the place... IsNull has an open paren but
no close paren, and the fieldname has a right bracket but no left bracket.

If you just don't want to see those records where other_pending_specify is
NULL, use a query criterion of IS NOT NULL on the field. No IIF is needed.

John W. Vinson [MVP]
 
Reply With Quote
 
GMC
Guest
Posts: n/a
 
      18th Jul 2007
OK, will try tomorrow and I see that error.

Thanks.


 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      19th Jul 2007
On Wed, 18 Jul 2007 16:12:29 -0600, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:

>>Iif(IsNull(other_pending_specify]="" ""[other_pending_specify])


IIF takes three arguments. If the first one is True, the function returns the
second argument; if it's False, it returns the third argument.

IsNull takes one argument and returns True if that argument is NULL, and False
if that argument contains data.

I'm not sure what you wanted this function to return - it *looks* like you
want it to return an empty string if other_pending_specify is NULL and return
the value in other_pending_specify if it's not, but that is precisely what
you'ld see if you just referenced other_pending_specify directly.

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Build A User Defined STR Statement Using Access 2000 =?Utf-8?B?U0VBTiBESScnJydBTk5P?= Microsoft Access VBA Modules 4 20th Mar 2006 09:46 PM
IIF statement in Report - Access 2000 Gale Coleman Microsoft Access 5 22nd Dec 2005 04:00 PM
iif statement with And statement in query (ms access 2000) =?Utf-8?B?Sk0gS2VsbHk=?= Microsoft Access 1 14th Apr 2005 06:28 AM
Access 2000 query SQL statement into VBA code =?Utf-8?B?Q2xpbnQ=?= Microsoft Access Queries 1 10th Jun 2004 01:33 PM
Validation Statement for ACCESS 2000 Kirk Microsoft Access 1 16th Jan 2004 04:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:13 PM.