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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing "ALL" or "*" from Combo Box to Query?

Status
Not open for further replies.

CCRT

Technical User
Jul 27, 2005
14
US
I'm trying to add "*" to a combo box and then pass it to a query. to select all records. I've used faq702-4538 as best I can but cannot get it to query without error.

Here is the SQL for the Combo Box (This works as it adds the "*" to the combo box)

SELECT qryComponentNumber.ComponentNumber FROM qryComponentNumber UNION SELECT "*" FROM qryComponentNumber
ORDER BY qryComponentNumber.ComponentNumber;


Here is the SQL for the query

"SELECT tblMFGItems.ComponentNumber, tblMFGItems.ManufactureName, tblMFGItems.ManufactureNumber, tblMFGItems.Status, tblMFGItems.RoHS, tblMFGItems.Preferred
FROM tblMFGItems
WHERE (((tblMFGItems.ComponentNumber)=[Forms]![frmCboLookup]![Combo0])) OR ((([Forms]![frmCboLookup]![Combo0])="*"));"

The query throws and error " Data type mismatch in the criteria expression"

Thanks for any help

--Dave



 
Did you check your Data Types of the fields you are using in the table design view?

-pmkieffe
 
Seems that tblMFGItems.ComponentNumber is defined as numeric.
Simply replace "*" with any numeric value not valid for ComponentNumber (eg 0 or -1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
SQL for the combo:
SELECT ComponentNumber FROM qryComponentNumber
UNION SELECT 'All' FROM qryComponentNumber
ORDER BY 1

SQL for the Query:
SELECT ComponentNumber, ManufactureName, ManufactureNumber, Status, RoHS, Preferred
FROM tblMFGItems
WHERE [Forms]![frmCboLookup]![Combo0] In (ComponentNumber, 'All')

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top