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

query is 'too complex to be evaluated'

Status
Not open for further replies.

Tattyfur

Technical User
Apr 15, 2011
3
GB
I have a form with a textbox that is being used as a criteria for a query

When I run the query I get 'this expresion is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elemnts. Try simplifying the expression by assigning parts of the expression to variables.'

The text Box passes a DateAdd function of the form >=DateAdd("m",-3,Date())

If I enter this value directly the query works, if it is entered as [Forms]![ReportSection].[DateQuery] it throws up this error.

I can't think of any way to simplify this expression to give me what I need.

Please someone help!

Here is my query

SELECT Invoice.DateSent, DealerDistributor.DealerDistName, Invoice.InvoiceNumber, NewUnit.UnitType, NewUnit.Zones, NewUnit.Upgrade, NewUnit.TeamviewerCode
FROM (DealerDistributor INNER JOIN Invoice ON DealerDistributor.DealerDistName = Invoice.DealerDistName) INNER JOIN NewUnit ON Invoice.InvoiceNumber = NewUnit.InvoiceNumber
WHERE (((Invoice.DateSent)=[Forms]![ReportSection].[DateQuery]) AND ((NewUnit.Status)="Sent"));
 
How can I pass the query a range of Dates to process then? Is there something simple I can do?
 
Do you mean you want a query with that as your criteria?

Code:
SELECT Invoice.DateSent, DealerDistributor.DealerDistName, Invoice.InvoiceNumber, NewUnit.UnitType, NewUnit.Zones, NewUnit.Upgrade, NewUnit.TeamviewerCode
FROM (DealerDistributor INNER JOIN Invoice ON DealerDistributor.DealerDistName = Invoice.DealerDistName) INNER JOIN NewUnit ON Invoice.InvoiceNumber = NewUnit.InvoiceNumber
WHERE (((Invoice.DateSent)>=DateAdd("m", -3, [Forms]![ReportSection].[DateQuery])) AND ((NewUnit.Status)="Sent"));

Or do you mean you want some sort to build your criteria dynamically?

In this case you would modify the SQL statemt for the query in code.... To get you started, it is the SQL property of the DAO querydef object.
 
Between the two of you I have managed to get it to work, Cheers guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top