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  

combobox rowsource "All" if more than one in list



 
 
Thread Tools Display Modes
  #1  
Old April 23rd, 2010, 08:49 PM posted to microsoft.public.access.forms
deb
external usenet poster
 
Posts: 898
Default combobox rowsource "All" if more than one in list

access 2003

I have a combobox with the below row source. It contains a Union to add
"All units".

How can I edit this to only show "All Units" if there are more than one
selection in the combobox?

i.e.
if combobox rowsource has 3 units then "All Units" would be included.
if combobox rowsource has only 1 unitthen only list the one unit.

SELECT t000GFacts.UnitID, t000GFacts.Unit, t000GFacts.UnitType,
t000GFacts.AEIC, t000GFacts.PlantName, t000GFacts.Unit AS UnitOrder,
t000GFacts.SiteName, t000GFacts.OperatingCompany AS Customer,
t000GFacts.ProjectNo, t000GFacts.SiteID, t000GFacts.PlantID,
t040Project.ProjectID FROM t040Project INNER JOIN (t000GFacts INNER JOIN
t041ProjectDetails ON t000GFacts.UnitID = t041ProjectDetails.UnitID) ON
t040Project.ProjectID = t041ProjectDetails.ProjectID WHERE
(((t040Project.ProjectID) Like [Forms]![f001ProjectReview]![ProjectID]))

UNION SELECT 0 AS UnitID, "All Units" AS Unit, "" AS UnitType, "" AS AEIC,
"" AS PlantName, "" AS UnitOrder, "" AS SiteName, "" AS Customer, "" AS
ProjectNo, "" AS SiteID, "" AS PlantID, t040Project.ProjectID FROM
t040Project INNER JOIN (t000GFacts INNER JOIN t041ProjectDetails ON
t000GFacts.UnitID = t041ProjectDetails.UnitID) ON t040Project.ProjectID =
t041ProjectDetails.ProjectID WHERE (((t040Project.ProjectID) Like
[Forms]![f001ProjectReview]![ProjectID]))
ORDER BY t000GFacts.PlantName, t000GFacts.Unit;



Thanks bunches,

--
deb
  #2  
Old April 23rd, 2010, 09:36 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default combobox rowsource "All" if more than one in list

"deb" wrote in message
...
access 2003

I have a combobox with the below row source. It contains a Union to add
"All units".

How can I edit this to only show "All Units" if there are more than one
selection in the combobox?

i.e.
if combobox rowsource has 3 units then "All Units" would be included.
if combobox rowsource has only 1 unitthen only list the one unit.

SELECT t000GFacts.UnitID, t000GFacts.Unit, t000GFacts.UnitType,
t000GFacts.AEIC, t000GFacts.PlantName, t000GFacts.Unit AS UnitOrder,
t000GFacts.SiteName, t000GFacts.OperatingCompany AS Customer,
t000GFacts.ProjectNo, t000GFacts.SiteID, t000GFacts.PlantID,
t040Project.ProjectID FROM t040Project INNER JOIN (t000GFacts INNER JOIN
t041ProjectDetails ON t000GFacts.UnitID = t041ProjectDetails.UnitID) ON
t040Project.ProjectID = t041ProjectDetails.ProjectID WHERE
(((t040Project.ProjectID) Like [Forms]![f001ProjectReview]![ProjectID]))

UNION SELECT 0 AS UnitID, "All Units" AS Unit, "" AS UnitType, "" AS AEIC,
"" AS PlantName, "" AS UnitOrder, "" AS SiteName, "" AS Customer, "" AS
ProjectNo, "" AS SiteID, "" AS PlantID, t040Project.ProjectID FROM
t040Project INNER JOIN (t000GFacts INNER JOIN t041ProjectDetails ON
t000GFacts.UnitID = t041ProjectDetails.UnitID) ON t040Project.ProjectID =
t041ProjectDetails.ProjectID WHERE (((t040Project.ProjectID) Like
[Forms]![f001ProjectReview]![ProjectID]))
ORDER BY t000GFacts.PlantName, t000GFacts.Unit;



I'm not sure I'm going to get this right without setting up tables to test
with, but try this:

SELECT t000GFacts.UnitID, t000GFacts.Unit, t000GFacts.UnitType,
t000GFacts.AEIC, t000GFacts.PlantName, t000GFacts.Unit AS UnitOrder,
t000GFacts.SiteName, t000GFacts.OperatingCompany AS Customer,
t000GFacts.ProjectNo, t000GFacts.SiteID, t000GFacts.PlantID,
t040Project.ProjectID FROM t040Project INNER JOIN (t000GFacts INNER JOIN
t041ProjectDetails ON t000GFacts.UnitID = t041ProjectDetails.UnitID) ON
t040Project.ProjectID = t041ProjectDetails.ProjectID WHERE
(((t040Project.ProjectID) Like [Forms]![f001ProjectReview]![ProjectID]))
UNION ALL
SELECT 0 AS UnitID, "All Units" AS Unit, "" AS UnitType, "" AS AEIC,
"" AS PlantName, "" AS UnitOrder, "" AS SiteName, "" AS Customer, "" AS
ProjectNo, "" AS SiteID, "" AS PlantID, t040Project.ProjectID FROM
t040Project INNER JOIN (t000GFacts INNER JOIN t041ProjectDetails ON
t000GFacts.UnitID = t041ProjectDetails.UnitID) ON t040Project.ProjectID =
t041ProjectDetails.ProjectID WHERE (((t040Project.ProjectID) Like
[Forms]![f001ProjectReview]![ProjectID]))
GROUP BY 0, t040Project.ProjectID
HAVING Count(*) 0
ORDER BY t000GFacts.PlantName, t000GFacts.Unit;


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old April 23rd, 2010, 09:48 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default combobox rowsource "All" if more than one in list

"Dirk Goldgar" wrote in message
...

I'm not sure I'm going to get this right without setting up tables to test
with, but try this:

SELECT t000GFacts.UnitID, t000GFacts.Unit, t000GFacts.UnitType,
t000GFacts.AEIC, t000GFacts.PlantName, t000GFacts.Unit AS UnitOrder,
t000GFacts.SiteName, t000GFacts.OperatingCompany AS Customer,
t000GFacts.ProjectNo, t000GFacts.SiteID, t000GFacts.PlantID,
t040Project.ProjectID FROM t040Project INNER JOIN (t000GFacts INNER JOIN
t041ProjectDetails ON t000GFacts.UnitID = t041ProjectDetails.UnitID) ON
t040Project.ProjectID = t041ProjectDetails.ProjectID WHERE
(((t040Project.ProjectID) Like [Forms]![f001ProjectReview]![ProjectID]))
UNION ALL
SELECT 0 AS UnitID, "All Units" AS Unit, "" AS UnitType, "" AS AEIC,
"" AS PlantName, "" AS UnitOrder, "" AS SiteName, "" AS Customer, "" AS
ProjectNo, "" AS SiteID, "" AS PlantID, t040Project.ProjectID FROM
t040Project INNER JOIN (t000GFacts INNER JOIN t041ProjectDetails ON
t000GFacts.UnitID = t041ProjectDetails.UnitID) ON t040Project.ProjectID =
t041ProjectDetails.ProjectID WHERE (((t040Project.ProjectID) Like
[Forms]![f001ProjectReview]![ProjectID]))
GROUP BY 0, t040Project.ProjectID
HAVING Count(*) 0
ORDER BY t000GFacts.PlantName, t000GFacts.Unit;



Correction:

HAVING Count(*) 1

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #4  
Old April 23rd, 2010, 10:01 PM posted to microsoft.public.access.forms
deb
external usenet poster
 
Posts: 898
Default combobox rowsource "All" if more than one in list

works like a dream!!!
--
deb


"Dirk Goldgar" wrote:

"Dirk Goldgar" wrote in message
...

I'm not sure I'm going to get this right without setting up tables to test
with, but try this:

SELECT t000GFacts.UnitID, t000GFacts.Unit, t000GFacts.UnitType,
t000GFacts.AEIC, t000GFacts.PlantName, t000GFacts.Unit AS UnitOrder,
t000GFacts.SiteName, t000GFacts.OperatingCompany AS Customer,
t000GFacts.ProjectNo, t000GFacts.SiteID, t000GFacts.PlantID,
t040Project.ProjectID FROM t040Project INNER JOIN (t000GFacts INNER JOIN
t041ProjectDetails ON t000GFacts.UnitID = t041ProjectDetails.UnitID) ON
t040Project.ProjectID = t041ProjectDetails.ProjectID WHERE
(((t040Project.ProjectID) Like [Forms]![f001ProjectReview]![ProjectID]))
UNION ALL
SELECT 0 AS UnitID, "All Units" AS Unit, "" AS UnitType, "" AS AEIC,
"" AS PlantName, "" AS UnitOrder, "" AS SiteName, "" AS Customer, "" AS
ProjectNo, "" AS SiteID, "" AS PlantID, t040Project.ProjectID FROM
t040Project INNER JOIN (t000GFacts INNER JOIN t041ProjectDetails ON
t000GFacts.UnitID = t041ProjectDetails.UnitID) ON t040Project.ProjectID =
t041ProjectDetails.ProjectID WHERE (((t040Project.ProjectID) Like
[Forms]![f001ProjectReview]![ProjectID]))
GROUP BY 0, t040Project.ProjectID
HAVING Count(*) 0
ORDER BY t000GFacts.PlantName, t000GFacts.Unit;



Correction:

HAVING Count(*) 1

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




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 06:55 PM.


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