My Assistant
![]() ![]() |
|
|
Sep 2 2006, 10:31 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 116 |
I have a query that is giving me this error:
This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables. (Error 3071) When I type in the criteria field "<=20" the query runs fine. When I change it to [Input <= or >= number of hours], and I type in the parameter, I get the error above. It will run if I delete out all the records (found that out when I was going to attach the database), but gives me the error when I have records. Just boggles me why it works if I actually put in the criteria versus when asked as a parameter. Can someone help me with this? Thanks. |
|
|
|
Sep 2 2006, 11:09 AM
Post
#2
|
|
|
VIP Emeritus Posts: 2,952 From: Clearwater, Florida |
Not sure what you are doing here [Input <= or >= number of hours]. but let me help you with the first part and you'll probably get it from there.
<=[Input Question Here] |
|
|
|
Sep 2 2006, 11:10 AM
Post
#3
|
|
|
UtterAccess VIP Posts: 5,283 From: Upstate NY, USA |
I don't think you can enter operators as a parameter.
A parameter has to be an exceptable data type. |
|
|
|
Sep 2 2006, 11:39 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 4,308 |
When I use [Input <= or >= number of hours] as a parameter I get no errors.
The [Input <= or >= number of hours] is displayed in the message box though. |
|
|
|
Sep 2 2006, 01:04 PM
Post
#5
|
|
|
UtterAccess Addict Posts: 116 |
Okay, this answers my question, along with the following 2 posts. I'm trying to do something that can't be done. So how best should I go about accomplishing what I am trying to do? How do I get someone to enter in either >= or <= number of hours to run the query? I want it to be flexible to be less than or greater than.
|
|
|
|
Sep 2 2006, 01:38 PM
Post
#6
|
|
|
UtterAccess VIP Posts: 4,308 |
What are you trying to do?
Do you want to allow the user to specify the operator to use for the criteria? |
|
|
|
Sep 2 2006, 01:44 PM
Post
#7
|
|
|
UtterAccess Addict Posts: 116 |
Yes.
|
|
|
|
Sep 2 2006, 01:49 PM
Post
#8
|
|
|
UtterAccess VIP Posts: 5,283 From: Upstate NY, USA |
Some options are:
Create two queries and decide which one to use based on the user input Create one query and change the .SQL property of the QueryDef object based on user input. Create an SQL string based on the user input and set the Recordsource of whatever you're opening to the SQL string. |
|
|
|
Sep 2 2006, 01:52 PM
Post
#9
|
|
|
UtterAccess VIP Posts: 5,200 From: Denver, Colorado [USA] |
It is generally not considered good practice to give a user direct access to a query. Users should interact with forms and reports.
Even if you want to keep the end result a query, I would suggest a form to enter the parameters and fire off the appropriate query (the less than query or the greater than query), rather than trying to combine this in one query with parameters entered at the query level. With a form, you can validate what the user enters and act appropriately; if you leave the parameter entry in the query itself, you have no real control. |
|
|
|
Sep 2 2006, 02:57 PM
Post
#10
|
|
|
UtterAccess Addict Posts: 116 |
I was trying to avoid adding even more forms and queries to what I feel is an already large database, but if that is what I need to do, then that is what I will do.
Thank you to everyone for your input and help. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 20th June 2013 - 12:06 AM |