Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2005

Tip: Looking for answers? Try searching our database.

Please help tweak my AND query.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Horne - 14 Nov 2005 16:06 GMT
Hi guys, I have the following query:

SELECT Quotations.QuotationID, Quotations.Date,
Quotations.Quotation_Customer_Lookup, Quotations.[Your Reference],
Quotations.QuotationBy, Quotation_Details.[Item No],
Quotation_Details.Product_lookup, Quotation_Details.[Full Description],
Quotation_Details.[Type/Colour/Size], Quotation_Details.Quantity,
Quotation_Details.[Denomination Lookup], Quotation_Details.Price
FROM Quotations INNER JOIN Quotation_Details ON Quotations.QuotationID =
Quotation_Details.QuotationID
WHERE (((Quotations.Quotation_Customer_Lookup) Like "*" & [cboCompanyName])
AND ((Quotations.[Your Reference]) Like "*" & [QuoteRef]) AND
((Quotations.QuotationBy)=[cboQuoteBy]) AND
((Quotation_Details.Product_lookup) Like "*" & [cboProduct]) AND
((Quotation_Details.[Full Description]) Like "*" & [txtDescription] & "*")
AND ((Quotation_Details.[Type/Colour/Size]) Like "*" & [txtTypeColourSize] &
"*"))
ORDER BY Quotations.QuotationID DESC;

This filters out results according to selections made in combo boxes or by
text typed in txt boxes. But the results are only shown if two or more boxes
are filled in. What do I need to do to this query to make it so?

For example, one of the fields cboCompanyName contains a list of all our
customers. This query should show all quotations for the company chosen in
the list, but at the moment it will only show results if one of the other
querying combo/text boxes is filled in. I assume this is something to do with
the ANDs but I'm not sure.
Ofer - 14 Nov 2005 16:36 GMT
Hi Richard
How come this criteria
Quotations.QuotationBy)=[cboQuoteBy])

Is not like the rest of them, with like
Quotations.QuotationBy) Like "*" & [cboQuoteBy]

If the cboQuoteBy wont be selected then no value will be displayed.

Signature

I hope that helped
Good Luck

> Hi guys, I have the following query:
>
[quoted text clipped - 24 lines]
> querying combo/text boxes is filled in. I assume this is something to do with
> the ANDs but I'm not sure.
Richard Horne - 14 Nov 2005 16:40 GMT
Hi

> Quotations.QuotationBy) Like "*" & [cboQuoteBy]

Is like that because when I had it as a Like "*" query,  the results were
inconsistent. For example the two users with ids 6 and 16 would show the same
results because 6 is like 16.

I guessed that that line is the root of my problem but I can't figure out
how best to code it without using the Like statement.

> Hi Richard
> How come this criteria
[quoted text clipped - 33 lines]
> > querying combo/text boxes is filled in. I assume this is something to do with
> > the ANDs but I'm not sure.
Ofer - 14 Nov 2005 17:06 GMT
Try this

Quotations.QuotationBy Like Nz([cboQuoteBy],"*")

Signature

I hope that helped
Good Luck

> Hi
>
[quoted text clipped - 44 lines]
> > > querying combo/text boxes is filled in. I assume this is something to do with
> > > the ANDs but I'm not sure.
Richard Horne - 14 Nov 2005 17:13 GMT
That did the trick Ofer. Thank you very much mate.

> Try this
>
[quoted text clipped - 48 lines]
> > > > querying combo/text boxes is filled in. I assume this is something to do with
> > > > the ANDs but I'm not sure.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.