IIF FUNCTION

R

Renee

I HAVE A REPORT THAT BRINGS UP INFORMATION BASED ON A FIELD CALLED 'LOADER',
I ALSO HAVE ANOTHER FIELD CALLED 'SCALE DESCRIPTION' IN THE QUERY FOR THIS
REPORT. I WANT THE REPORT TO DISPLAY THE UNIT LISTED UNDER 'LOADER' ONLY IF
THE FIELD 'SCALE DESCRIPTION' IS BLANK, IF IT IS NOT BLANK THEN I WANT IT TO
SHOW ME THE UNIT LISTED UNDER 'SCALE DESCRIPTION' INSTEAD. IS THIS POSSIBLE?
 
K

Ken Snell \(MVP\)

I usually do this in the query itself:

SELECT T.[Loader], T.[Scale Description],
IIf(Len(T.[Loader] & "")>0, T.[Loader], T.[Scale Description])
AS ValueToShow
FROM TableName AS T;

Bind the textbox in the report to the ValueToShow field.
 
R

Renee

I AM NOT SURE I UNDERSTAND WHERE I WOULD PUT THAT IN THE QUERY

Ken Snell (MVP) said:
I usually do this in the query itself:

SELECT T.[Loader], T.[Scale Description],
IIf(Len(T.[Loader] & "")>0, T.[Loader], T.[Scale Description])
AS ValueToShow
FROM TableName AS T;

Bind the textbox in the report to the ValueToShow field.

--

Ken Snell
<MS ACCESS MVP>


Renee said:
I HAVE A REPORT THAT BRINGS UP INFORMATION BASED ON A FIELD CALLED
'LOADER',
I ALSO HAVE ANOTHER FIELD CALLED 'SCALE DESCRIPTION' IN THE QUERY FOR THIS
REPORT. I WANT THE REPORT TO DISPLAY THE UNIT LISTED UNDER 'LOADER' ONLY
IF
THE FIELD 'SCALE DESCRIPTION' IS BLANK, IF IT IS NOT BLANK THEN I WANT IT
TO
SHOW ME THE UNIT LISTED UNDER 'SCALE DESCRIPTION' INSTEAD. IS THIS
POSSIBLE?
 
K

Ken Snell \(MVP\)

Please do not use ALL CAPS -- it's interpreted as "shouting" in newsgroups.

What I provided is a sample SQL statement -- which is a query. Note the IIf
function in the third "field" in the statement; that is an example of how
this is done.

If you're using the grid design view to create a query, go to the first
empty column and click in the Field: box. Type this:

ValueToShow: IIf(Len([Loader] & "")>0, [Loader], [Scale Description])

--

Ken Snell
<MS ACCESS MVP>



Renee said:
I AM NOT SURE I UNDERSTAND WHERE I WOULD PUT THAT IN THE QUERY

Ken Snell (MVP) said:
I usually do this in the query itself:

SELECT T.[Loader], T.[Scale Description],
IIf(Len(T.[Loader] & "")>0, T.[Loader], T.[Scale Description])
AS ValueToShow
FROM TableName AS T;

Bind the textbox in the report to the ValueToShow field.

--

Ken Snell
<MS ACCESS MVP>


Renee said:
I HAVE A REPORT THAT BRINGS UP INFORMATION BASED ON A FIELD CALLED
'LOADER',
I ALSO HAVE ANOTHER FIELD CALLED 'SCALE DESCRIPTION' IN THE QUERY FOR
THIS
REPORT. I WANT THE REPORT TO DISPLAY THE UNIT LISTED UNDER 'LOADER'
ONLY
IF
THE FIELD 'SCALE DESCRIPTION' IS BLANK, IF IT IS NOT BLANK THEN I WANT
IT
TO
SHOW ME THE UNIT LISTED UNDER 'SCALE DESCRIPTION' INSTEAD. IS THIS
POSSIBLE?
 
R

Renee

Thank you very much, that works out wonderfully.

Ken Snell (MVP) said:
Please do not use ALL CAPS -- it's interpreted as "shouting" in newsgroups.

What I provided is a sample SQL statement -- which is a query. Note the IIf
function in the third "field" in the statement; that is an example of how
this is done.

If you're using the grid design view to create a query, go to the first
empty column and click in the Field: box. Type this:

ValueToShow: IIf(Len([Loader] & "")>0, [Loader], [Scale Description])

--

Ken Snell
<MS ACCESS MVP>



Renee said:
I AM NOT SURE I UNDERSTAND WHERE I WOULD PUT THAT IN THE QUERY

Ken Snell (MVP) said:
I usually do this in the query itself:

SELECT T.[Loader], T.[Scale Description],
IIf(Len(T.[Loader] & "")>0, T.[Loader], T.[Scale Description])
AS ValueToShow
FROM TableName AS T;

Bind the textbox in the report to the ValueToShow field.

--

Ken Snell
<MS ACCESS MVP>


I HAVE A REPORT THAT BRINGS UP INFORMATION BASED ON A FIELD CALLED
'LOADER',
I ALSO HAVE ANOTHER FIELD CALLED 'SCALE DESCRIPTION' IN THE QUERY FOR
THIS
REPORT. I WANT THE REPORT TO DISPLAY THE UNIT LISTED UNDER 'LOADER'
ONLY
IF
THE FIELD 'SCALE DESCRIPTION' IS BLANK, IF IT IS NOT BLANK THEN I WANT
IT
TO
SHOW ME THE UNIT LISTED UNDER 'SCALE DESCRIPTION' INSTEAD. IS THIS
POSSIBLE?
 
K

Ken Snell \(MVP\)

You're welcome.

--

Ken Snell
<MS ACCESS MVP>


Renee said:
Thank you very much, that works out wonderfully.

Ken Snell (MVP) said:
Please do not use ALL CAPS -- it's interpreted as "shouting" in
newsgroups.

What I provided is a sample SQL statement -- which is a query. Note the
IIf
function in the third "field" in the statement; that is an example of how
this is done.

If you're using the grid design view to create a query, go to the first
empty column and click in the Field: box. Type this:

ValueToShow: IIf(Len([Loader] & "")>0, [Loader], [Scale Description])

--

Ken Snell
<MS ACCESS MVP>



Renee said:
I AM NOT SURE I UNDERSTAND WHERE I WOULD PUT THAT IN THE QUERY

:

I usually do this in the query itself:

SELECT T.[Loader], T.[Scale Description],
IIf(Len(T.[Loader] & "")>0, T.[Loader], T.[Scale Description])
AS ValueToShow
FROM TableName AS T;

Bind the textbox in the report to the ValueToShow field.

--

Ken Snell
<MS ACCESS MVP>


I HAVE A REPORT THAT BRINGS UP INFORMATION BASED ON A FIELD CALLED
'LOADER',
I ALSO HAVE ANOTHER FIELD CALLED 'SCALE DESCRIPTION' IN THE QUERY
FOR
THIS
REPORT. I WANT THE REPORT TO DISPLAY THE UNIT LISTED UNDER 'LOADER'
ONLY
IF
THE FIELD 'SCALE DESCRIPTION' IS BLANK, IF IT IS NOT BLANK THEN I
WANT
IT
TO
SHOW ME THE UNIT LISTED UNDER 'SCALE DESCRIPTION' INSTEAD. IS THIS
POSSIBLE?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top