Setting Criteria for a Query in a Control on a Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wish to set the criteria for a field in a query on a control on a form. The
datasource on the control is:

"Between ""000"" And ""zzz"""

The problem, as far as I can tell, is that the query is not interpretting
the data as an operator, it's intrepretting it as an expression, because when
it runs it does not return any records. Any suggestsions?
 
The "datasource" for controls either relates to a specific field in the
underlying table/query, or is a query in its own right. You can't just enter
"Between ""000"" And "zzz""". Besides how do you expect Access to work out
the values between a number (000) and three characters ("zzz")?

Which control are you talking about?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
It is the datasource for an unbound text box. The criteria field in my query
is:

Forms![MyForm]![TextBox]

The parameters "000" and "zzz" work in my database. When I paste the
expression in the field criteria, it returns the correct records. But what I
need is for this expression (Between "000" and "zzz") to be generated in a
form, and then passed on to the criteria field.

Thansk for your help.
 
Sorry, I don't understand what you're trying to do.

You use the word "datasource" - do you mean ControlSource? If so, I don't
understand why you would want to set the textbox's ControlSource to a
partial expression, because the textbox can't get its data from a partial
expression.

I understand that you want to put "Between '000' And 'zzz'" into an SQL
query, but I don't see why the textbox is involved at all, because it can't
accept the results of the query (unless there's somethign else going on that
i don't know about). Do you intend for the user to enter their own criteria
expression, and have *that* put into the query?

What are you trying to do?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Murp said:
It is the datasource for an unbound text box. The criteria field in my
query
is:

Forms![MyForm]![TextBox]

The parameters "000" and "zzz" work in my database. When I paste the
expression in the field criteria, it returns the correct records. But what
I
need is for this expression (Between "000" and "zzz") to be generated in a
form, and then passed on to the criteria field.

Thansk for your help.

Graham R Seach said:
The "datasource" for controls either relates to a specific field in the
underlying table/query, or is a query in its own right. You can't just
enter
"Between ""000"" And "zzz""". Besides how do you expect Access to work
out
the values between a number (000) and three characters ("zzz")?

Which control are you talking about?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top