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

"like" parameter in Union query 2

Status
Not open for further replies.

simon551

IS-IT--Management
May 4, 2005
249
Hi,
I have a union query of union queries and I'm trying to put in a parameter but it's not working.

Select * FROM qryUNIONPurchases UNION SELECT * From qryUNIONSales
WHERE [CO] Like Forms!frmRegister.txtCo & "*"
ORDER BY TransDate;


The parameter never filters. On background: the field [CO] is a made up field in the underlying queries. There is no table data to back up the field.

Thanks in advance,
Simon
 
WHERE [CO] Like Forms!frmRegister.txtCo & "*"

If the textbox holds the text "abcde" then the SQL needs to end up be something like:
[TT]
WHERE [CO] Like "abcde*"
[/TT]
but your code isn't supplying that first quote. Try:
[TT]
WHERE [CO] Like "'" & Forms!frmRegister.txtCo & "*'"
[/TT]

Geoff Franklin
 
i think the reason is [CO] is not any field in your database as you mentioned...

how did you form [CO]...just replace [CO] with the definition of [CO]

-DNG
 
I set up a database that links to 3 very similar databases. There are 3 queries that make up each Union query that this union query is combining. I set up a field in the original query that is CO:myCompany to reference where the data is coming from. I'm not sure how else I could do this.
 
This works!
Select * FROM qryUNIONPurchases WHERE [CO] Like "*" & Forms!frmRegister.txtCo & "" UNION SELECT * From qryUNIONSales
WHERE [CO] Like "*" & Forms!frmRegister.txtCo & ""
ORDER BY TransDate;

Thank you!
 
SELECT * FROM (
Select * FROM qryUNIONPurchases UNION SELECT * From qryUNIONSales
) AS U WHERE U.CO Like Forms!frmRegister.txtCo & "*"
ORDER BY U.TransDate;

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