A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Combo box to display something else if field is blank



 
 
Thread Tools Display Modes
  #1  
Old January 29th, 2010, 04:22 AM posted to microsoft.public.access.forms
Rachel
external usenet poster
 
Posts: 187
Default Combo box to display something else if field is blank

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
  #2  
Old January 29th, 2010, 05:13 AM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Combo box to display something else if field is blank

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

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Rachel" wrote in message
news
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


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.