Solved

Access  Row Source Select Statement with If...else

Posted on 2009-05-19
2
764 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:murbro
[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 500 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:murbro
ID: 31583217
Thanks very much
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

739 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