Help with using form text box to change a query criteria

N

ngl1145

Hi,
I think I need some help from some of you. I created a simple query
where it looks at the textbox in my form as it's criteria. For example in my
query, I typed "=[Forms]![Form1]![Text0]". When I click the run query button
and I enter a set value.. say "10", the query will retrieve any records that
have "10" in the column which is great. But when I put a "<10" in the
textbox and I run the query, it gives me a "You canceled the previous
operation" message box. Is there a way I can use the Form textbox to run
conditional criteria like "<10"? Thanks for your help!!
 
M

Marshall Barton

ngl1145 said:
I think I need some help from some of you. I created a simple query
where it looks at the textbox in my form as it's criteria. For example in my
query, I typed "=[Forms]![Form1]![Text0]". When I click the run query button
and I enter a set value.. say "10", the query will retrieve any records that
have "10" in the column which is great. But when I put a "<10" in the
textbox and I run the query, it gives me a "You canceled the previous
operation" message box. Is there a way I can use the Form textbox to run
conditional criteria like "<10"?


No. The < needs to be in the query instead of the =
Generally, the text box can only contain a value (e.g. 10),
it can not be used to specify the comparison operator.

If you absolutely must allow users to specify the
comparison, you will need to use a different approach where
you use VBA code (probably using the BuildCriteria function)
to construct the query. Since you didn't say anything about
how the query is going to be used, I can't realistically
suggest anything more specific than that.
 
N

ngl1145

The criteria is used to obtain customer information based on priority level.
Currently the each customer has a priority number from 1 to 10. I'm setting
up a form that has a textbox where the user can specify if they want to pull
records that are defined such as "1" "2" etc... or if they want to obtain
customers who are a priority level of "<4". This is why I want to add
conditional statements to my query. I thought I could use vba to run an SQL
statement to do this but that did not work based on the string operations
that I was allowed. If you can direct me in another direction that would be
great.

Marshall said:
I think I need some help from some of you. I created a simple query
where it looks at the textbox in my form as it's criteria. For example in my
[quoted text clipped - 4 lines]
operation" message box. Is there a way I can use the Form textbox to run
conditional criteria like "<10"?

No. The < needs to be in the query instead of the =
Generally, the text box can only contain a value (e.g. 10),
it can not be used to specify the comparison operator.

If you absolutely must allow users to specify the
comparison, you will need to use a different approach where
you use VBA code (probably using the BuildCriteria function)
to construct the query. Since you didn't say anything about
how the query is going to be used, I can't realistically
suggest anything more specific than that.
 
M

Marshall Barton

What do you mean by "run an SQL statement to do this", both
the word "run" and the word "this" have no meaning without
more information. There are ways to do what you want (plus
a lot more), but it depends on the details of what you are
trying to accomplish.
--
Marsh
MVP [MS Access]

The criteria is used to obtain customer information based on priority level.
Currently the each customer has a priority number from 1 to 10. I'm setting
up a form that has a textbox where the user can specify if they want to pull
records that are defined such as "1" "2" etc... or if they want to obtain
customers who are a priority level of "<4". This is why I want to add
conditional statements to my query. I thought I could use vba to run an SQL
statement to do this but that did not work based on the string operations
that I was allowed. If you can direct me in another direction that would be
great.

Marshall said:
I think I need some help from some of you. I created a simple query
where it looks at the textbox in my form as it's criteria. For example in my
[quoted text clipped - 4 lines]
operation" message box. Is there a way I can use the Form textbox to run
conditional criteria like "<10"?

No. The < needs to be in the query instead of the =
Generally, the text box can only contain a value (e.g. 10),
it can not be used to specify the comparison operator.

If you absolutely must allow users to specify the
comparison, you will need to use a different approach where
you use VBA code (probably using the BuildCriteria function)
to construct the query. Since you didn't say anything about
how the query is going to be used, I can't realistically
suggest anything more specific than that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top