query help [attn: Emilia M.]

query help [attn: Emilia M.]

Post by Gurt » Thu, 03 Jul 2003 22:48:19


Actually, that should be 'field1' and 'field2' rather
than 'row1' and 'row2'. :)
 
 
 

query help [attn: Emilia M.]

Post by Elwi » Thu, 03 Jul 2003 23:13:00

I don't believe you can place a SQL string directly into
the RecordSource property with a variable comparison
operator, in this case and/or.

You should build the SQL string in code. Here's an
example. The syntax is correct, just substitute the
actual table, field, form, and control names. You could
run this from the OnClick() event of a command button or
almost any other event you deem appropriate. Good luck.

Dim strSQL as string
strSQL = "SELECT table.* FROM table " _
& "WHERE [Field1] Like '*" & Forms!MyForm!CBox1 _
& "*' " & Forms!MyForm!Logic.Caption _
& " [Field2] Like '*" & Forms!MyForm!CBox2 & "*'"
Forms!MyOtherForm.RecordSource = strSQL



concatenating
replace
&

 
 
 

query help [attn: Emilia M.]

Post by Andy Col » Fri, 04 Jul 2003 00:16:49

Gurtz

See my response to your previous thread

Andy
 
 
 

query help [attn: Emilia M.]

Post by Elwi » Fri, 04 Jul 2003 00:58:16

You could simply add another wildcard, but order matters.

This returns true:
"the black may fly again." Like "*black*fly*"

This returns false:
"the fly may be black." Like "*black*fly*"

If you need more advanced search capabilities you really
have no other choice than to parse out the criteria. Good
luck.

how
as "the
holds
& "* "
of