"NOT Search" not working

C

Chris Crook

Hey all,

I am really new with VBA, but I am trying to write code for a search
engine that will read AND, OR, NOT, and search for x AND y...etc. So
far the AND & OR work fine, however the NOT does not work. here is my
code, any help would be appreciated:

Public Function fncReplaceTxt(txt As String)

Dim rpltxtAND As String
Dim rpltxtNOT As String
Dim rpltxtOR As String

Dim stmSQL As String
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.SetWarnings (False)

rpltxtAND = Replace(txt, " and ", "*"" And (tblmain.Article) Like
""*")
rpltxtNOT = Replace(rpltxtAND, " not ", "*"" Not (tblmain.Article)
Like ""*")
rpltxtOR = Replace(rpltxtNOT, " or ", "*"" Or (tblmain.Article) Like
""*")

stmSQL = "SELECT tblmain.article, tblmain.title, tblmain.date,
tblmain.ID INTO tblquery FROM tblmain WHERE (((tblmain.Article) Like
""*" & rpltxtOR & "*""));"



DoCmd.RunSQL stmSQL

stDocName = "Form2"


DoCmd.OpenForm stDocName, , , stLinkCriteria

End Function


thanks,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top