473,512 Members | 15,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display text in a query based on a condition

4 New Member
I am creating a query in Access 2003 that basically displays data in certain fields in a table (plain and simple basic stuff). I have a field in the table that may or may not contain data. If the field contains data I want that data to display. If it does not contain data I want the query to check another field for a certain condition. If the condition is true I want to display specific text in this column where normally nothing would be displayed because the field is blank. If the condition is false then displaying blank information is fine.


If this cannot be done the way I describe then I would be ok with creating a new column to display in the query that will show the desired text based on a true condition.
Jan 15 '08 #1
4 6544
jaxjagfan
254 Recognized Expert Contributor
I am creating a query in Access 2003 that basically displays data in certain fields in a table (plain and simple basic stuff). I have a field in the table that may or may not contain data. If the field contains data I want that data to display. If it does not contain data I want the query to check another field for a certain condition. If the condition is true I want to display specific text in this column where normally nothing would be displayed because the field is blank. If the condition is false then displaying blank information is fine.


If this cannot be done the way I describe then I would be ok with creating a new column to display in the query that will show the desired text based on a true condition.
You need to do an IIF(notice there are 2 i's).

Something similar to this:

Field1:IIF(Mytable.MyField1 is not null, Mytable.MyField1,IIF(Mytable.MyField2 = "sometext", "sometruetext", "somefalsetext"))
Jan 15 '08 #2
exrcizn
4 New Member
Ok, I have the IF statement which I'm sure is correct but...where do I put it on the query screen? I know this is a basic question but it's been a while since I've done this. Funny how I had no trouble with the IIF statement but can't figure out this part!

In the Query view window where you set up the columns to show in the output of the query do I put the IIF statement in the criteria section of the field I'm checking (the first mentioned field in your IIF statement example) or do I "create" a separate field...that's where I'm missing the knowledge of how to do this. If I put it in the criteria area of the field I'm checking against I get an error that says this:

You tried to execute a query that does not include the specified expression 'JobPosting.RequestPostingNumber=[Request Posting Number] And Application.Race=IIF(Not Application.Race Is Null....<insert the rest of the IIf statement you gave me here>...as part of an aggregate function.

The first referenced code part of this query is where I'm prompting for a specific Posting Number. This part works.

Basically I need to know where to put the IIf statement...

Thanks for your response!
Jan 15 '08 #3
exrcizn
4 New Member
Never mind...I got it!

Thanks so much for your help!
Jan 15 '08 #4
jaxjagfan
254 Recognized Expert Contributor
Never mind...I got it!

Thanks so much for your help!
Guess you realized that the IIF goes in the column name vice criteria.

Glad to help.
Jan 15 '08 #5

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

Similar topics

5
2239
by: Jerome | last post by:
Hi, I've got the following problem: I want my ASP page to display a certain number (based on a COUNT query), it works fine if the result is at least 1! If there are no records to be counted...
5
8201
by: Todd | last post by:
Data related to the query I'm working on is structured such that TableA and TableB are 1-many(optional). If an item on TableA has children on TableB, I need to use the Max(tstamp) from Table B in...
11
17252
by: deko | last post by:
I need to create different recordsets based on queries that use data from unbound fields in a form. I've discovered that I can't do this, and instead need to save the data in question (usually a...
2
18684
by: Dom | last post by:
I need to run a query based on a query in Access. The second query has a number of conditions which all work well, but there is one more contition I need to set to make it run properly. the...
2
4428
by: Marc | last post by:
I'm back in the Access development mode and seem to have forgotten how to do 2 things that should be simple. I have a database with a table of contacts, companies and activities. The idea is that...
2
4778
by: Corepaul | last post by:
As input is typed into a text box, I would like to search a recordset for the first record that matches what has been typed so far. I would like to update the text box to display the letters typed...
1
3994
by: maflatoun | last post by:
Hi, I have a datagrid and based on a condition I like to display either a asp:textbox or asp:label. How would I do that? I have the following <asp:TemplateColumn HeaderText="Qty">...
0
4071
by: Luke Herbert | last post by:
I am very new to C# and have been trying to get to grips with it by writing a small tool to detect a USB key being inserted and then backup user specified files to the key. I have written some...
3
3785
by: Coll | last post by:
I have a form that had been setup with a combo box. You'd select a value from the combo box and a query would open and display matching records. I now need to remove the combo box and set up a text...
0
7371
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,...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
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...
0
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.