Combo box to display something else if field is blank

R

Rachel

Hi I have a combo box in my form which uses the following query:

SELECT [CustomerID], [FirstName] & " " & [LastName] FROM Customers ORDER BY
[FirstName] & " " & [LastName]


However, if the both the firstname and lastname are blank in the Customer
Table I need it to show the BillingAddress instead.

Is this possible?

My line of thinking is something like this:
SELECT [CustomerID], [FirstName] & " " & [LastName] FROM Customers ORDER BY
[FirstName] & " " & [LastName]; IFBLANK SELECT [CustomerID], [BillingAddress]
FROM Customers ORDER BY [BillingAddress]

But it doesn't seem to be right!

Thanks so much :)
Rachel
 
A

Allen Browne

SELECT [CustomerID],
IIf([FirstName] Is Null AND [LastName] Is Null, [BillingAddress],
[FirstName] & " " & [LastName]) AS CustomerName
FROM Customers
ORDER BY [FirstName], [LastName];
 

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