?
Solved

Access  Row Source Select Statement with If...else

Posted on 2009-05-19
2
Medium Priority
?
807 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
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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

862 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