As the title states, I am having an issue with a query giving me an error stating that my expression is too complex when trying to filter calculated fields. I have searched around and have not found anything applicable to my specific use case and was hoping someone here could help me out.
Parameters:
“Jobsite Lat” – Data from Table
“Jobsite Long” – Data from Table
“SearchLat” – TempVar
“SearchLong” – TempVar
“SearchRad” – TempVar
“Distance” – Calculated Value
“projwcoord” – Source Table
Calculated Expression: (Put into “Field” field in query)
Distance: Sqr(((([Jobsite Lat]-[TempVars]![SearchLat])/0.011451)*(([Jobsite Lat]-[TempVars]![SearchLat])/0.011451))+((([Jobsite Long]-[TempVars]![SearchLong])/0.011451)*(([Jobsite Long]-[TempVars]![SearchLong])/0.011451)))
Desired Criteria (for Distance): Filter out Distance values above SearchRad
Syntax: “< [TempVars]![SearchRad]”
My issue is that I can run the query just fine when there is no criteria for “Distance”, however, as soon as I include the criteria, it gives me an error saying that the expression is too complex.
Additionally, I have tried to use a check variable to spit out “1” if the Distance value meets the criteria, and “0” if it does not, which works fine with no criteria, but again, if I try to use criteria to filter out any records with a check value of “0” (Syntax “Not Like “0””) I get a message asking me to declare the value of “Distance”
I am pretty stumped on this and would appreciate any help. I have included my SQL code below if that helps. I have not changed it as I am inexperienced with SQL and have used the design view up to this point. However, if it is required to get my desired outcome then I will be happy to learn. Thank you!
Using Check Value:
SELECT projwcoord.*, Sqr(((([Jobsite Lat]-[TempVars]![SearchLat])/0.011451)*(([Jobsite Lat]-[TempVars]![SearchLat])/0.011451))+((([Jobsite Long]-[TempVars]![SearchLong])/0.011451)*(([Jobsite Long]-[TempVars]![SearchLong])/0.011451))) AS Distance, IIf([Distance]<=[TempVars]![SearchRad],"1","0") AS [Check]
FROM projwcoord;
WHERE (((IIf([Distance]<=[TempVars]![SearchRad],"1","0")) Not Like "0"));
Filtering by Distance:
SELECT projwcoord.*, Sqr(((([Jobsite Lat]-[TempVars]![SearchLat])/0.011451)*(([Jobsite Lat]-[TempVars]![SearchLat])/0.011451))+((([Jobsite Long]-[TempVars]![SearchLong])/0.011451)*(([Jobsite Long]-[TempVars]![SearchLong])/0.011451))) AS Distance
FROM projwcoord
WHERE (((Sqr(((([Jobsite Lat]-[TempVars]![SearchLat])/0.011451)*(([Jobsite Lat]-[TempVars]![SearchLat])/0.011451))+((([Jobsite Long]-[TempVars]![SearchLong])/0.011451)*(([Jobsite Long]-[TempVars]![SearchLong])/0.011451))))<[TempVars]![SearchRad]));