Query Criteria from Form textbox not working. Ideas?

Vigilante001

A Jolly Fellow...
Local time
Today, 01:29
Joined
May 16, 2008
Messages
28
Hello all.

I have a query with a field A. The criteria for field A is dynamic with 10 user fields on a form, which the user can select only 1 or as many as 10 options to limit the search. After the user makes his/her selection, the form builds the criteria statement from the user choices and saves it all concatenated into one "Criteria" textbox. This "Criteria" textbox is what field A uses to limit the query. Now, here is the issue... lets take the example criteria:

(txtCCVar# are the 10 criteria fields the master criteria field builds from. The master criteria field is named: txtQueryCriteriaString)
Code:
Like  "*" & Forms![Expenditures]![txtCCVar1] & "*" Or Like "*" & Forms![Expenditures]![txtCCVar2] & "*"
When the content above is directly in field A's criteria slot in Design mode, it runs perfectly. However, if I link to that same content via...

Code:
Forms!Expenditures!txtQueryCriteriaString
...the query returns as empty. This usually works for me, so...is there something I am missing?

Thank you!
 
Idea. Is the query reading the textbox as a string and not as a command? Ex.

Does a query pointing to a textbox with...

Code:
Like  "*" & Forms![Expenditures]![txtCCVar1] & "*" Or Like "*" & Forms![Expenditures]![txtCCVar2] & "*"

...reading "Like" as a string, and instead of a command? Can form boxes only be referenced as values in criteria commands, and not as the command itself?
 
Last edited:
I'm having the same type of problem here except I have no idea what to put in "criteria" in order for my query to read in the number in the textbox. the number in the text box is the primary key for each specific form. I want my query only to return 1 result by only reading the RecordID number of the single open form. When I put the command "Forms!FormName!FieldName" and I run the query, a prompt windown comes up asking me to enter in the RecordID. When I enter the RecordID for the specific form, the query works fine, but I want the criteria portion to automatically read in the RecordID of the open form, so the user does not have to do this. Is this possible and if so how? Thank you.
 

Users who are viewing this thread

Back
Top Bottom