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
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