Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add "All" to combo box, based on form criteria 1

Status
Not open for further replies.

TimTDP

Technical User
Joined
Feb 15, 2004
Messages
373
Location
ZA
In Access 2000 I use the following SQL statement to add an "All" record to the results of a combo box:

SELECT ProductTypeId, ProductType, AgencyId FROM tblProductType UNION SELECT Ast, Desc,"" FROM tblAsterisk
ORDER BY tblProductType.ProductType;


I know need to limit the results, based on the value of a field on the form. I have modified the above SQL statement to:

SELECT ProductTypeId, ProductType, AgencyId FROM tblProductType UNION SELECT Ast, Desc,"" FROM tblAsterisk
WHERE AgencyId = [Forms]![frmOrganisation]![cboCurrentAgency]
ORDER BY tblProductType.ProductType;

When I run the code I am prompted for "AgencyId"

Where have I gone wrong?
 
I think that should go:

Code:
SELECT ProductTypeId, ProductType, AgencyId FROM tblProductType WHERE AgencyId = [Forms]![frmOrganisation]![cboCurrentAgency]
UNION SELECT Ast, Desc,"" FROM tblAsterisk
ORDER BY tblProductType.ProductType;

There is a possibility you will have trouble with Desc as a field name as it is a reserved word.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top