syntax (1 Viewer)

Lanason

Registered User.
Local time
Today, 07:43
Joined
Sep 12, 2003
Messages
258
can anyone tell me what wrong with the syntax of this please
code
Me.Filter = ("[DocNo] like " & Chr(34) & "*" & Me.search & "*" & Chr(34) & " " & "OR [DocTitle] like " & Chr(34) & "*" & Me.search & "*" & Chr(34)) And ([Doc Status] like 'Active'"
/code

regards Adrian
 

Minty

AWF VIP
Local time
Today, 07:43
Joined
Jul 26, 2013
Messages
10,366
Build the string into a variable and Debug.print it to see what it looks like in the immediate window.

I suspect it ends up with a quote in the wrong place. I think you have a ( outside of the quotes as well.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:43
Joined
May 21, 2018
Messages
8,516
You can help yourself with a variable
strSearch = "'*" & me.search & "*'"
"([DocNo] like " & strSearch & " OR [DocTitle] like " & strSearch & ") And [Doc Status] like 'Active'"

Also no space before the OR, and the parentheses look jacked .([Doc Status]
 

plog

Banishment Pending
Local time
Today, 01:43
Joined
May 11, 2011
Messages
11,634
You have an odd number of quote marks (they need to exist in pairs). And you have more opening parenthesis than closing parenthesis.

I agree with Minty. But my advice is to build this in a string, slowly. Add just one piece at a time until you have the whole thing rebuilt. That way you know which piece broke it:

FilterString = "([DocNo] LIKE "

STart with that then slowly add pieces until it is correct. A syntax error means the new piece isn't correct.
 

Lanason

Registered User.
Local time
Today, 07:43
Joined
Sep 12, 2003
Messages
258
Many thanks everyone now sorted - syntax is the worst thing ever.
Its like learning another language #lols
 

Users who are viewing this thread

Top Bottom