Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Criteria from text field on form

Status
Not open for further replies.

shiningblade

Programmer
Jan 25, 2002
25
CA
I would like to have the criteria of a field in my query to come from a text field on a form.

[Forms]![frmSearch]![txtComments] is populated by a VBA function that will parse and format text from another field. I then want to use [Forms]![frmSearch]![txtComments]as the criteria for the field [Comments] in qrySearch.

The problem I have is the syntax of [txtComments].

Say for instance I want the criteria of [Comments] to be:

Like "*contract*"

I actually have the criteria as [Forms]![frmSearch]![txtComments]

What does [Forms]![frmSearch]![txtComments] have to look like?

Thanks for any help you can give,

Jude

As you may be able to tell, formatting strings is not my strong point... yet. :)
 
Hopefully at QueryDef the following may work out

Select * from <TableName> where Comments = [Forms]![frmSearch]![txtComments]
Open the Form
Enter Value
Run QueryDef.


OR if u just form the query at runtime

Set Rst = Currentdb.openRecordSet(&quot;Select * from <TableName> where Comments = &quot; & [Forms]![frmSearch]![txtComments])


 
But what does the format of the string in [Forms]![frmSearch]![txtComments] have to look like?

Jude
 
Interesting Nested query ,
A query gets a set of records upon a criteria(user input) from a single table field, and a second query uses the first query and table to get the records with another criteria(user input) like this 2 more queries do serach their preceding queries...
can anyone suggest me how to do this ?? I would really appreciate it...

 


Like &quot;*&quot; & [Forms]![frmSearch]![txtComments] & &quot;*&quot;
 
The Comment field in form must have the value to be
compared

Assueme u need
Select * from <Table> where Comments = &quot;Sample&quot;

The Comment field must have the word sample.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top