?
Solved

Access  Row Source Select Statement with If...else

Posted on 2009-05-19
2
Medium Priority
?
778 Views
Last Modified: 2013-11-28
Hi

I have a form ComboBox control. In the RowSource I want to have a SQL statement that Selects the "Company" field from the "Contacts" table, but if this is blank then it selects the "First Name and "Last Name" together
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 24426499
Let me get this straight, from the contacts table, display company name but if that is null then display first and last name?

u can use iff

select iif(nz(Company,"")="",[First Name] & " " & [Last Name],Company) as Name


syntax is iif(condition,value if true,value if false)

nz is used to check for null string
0
 

Author Closing Comment

by:Murray Brown
ID: 31583217
Thanks very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question