Combo box to display something else if field is blank

  • Thread starter Thread starter Rachel
  • Start date Start date
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
 
SELECT [CustomerID],
IIf([FirstName] Is Null AND [LastName] Is Null, [BillingAddress],
[FirstName] & " " & [LastName]) AS CustomerName
FROM Customers
ORDER BY [FirstName], [LastName];
 
Back
Top