S
Squeekykilt
Guest
Hi All,
Have a slight problem, I am trying to create a search form for an access database which searches for a word (or several words) within a string of text held in one of the tables rows.
The code I have so far is as follows;
DoCmd.ShowAllRecords
DoCmd.GoToControl ("str_Problem")
DoCmd.FindRecord Me!txtsearch
str_problem.SetFocus
strProblemRef = str_problem.Text
txtsearch.SetFocus
strSearch = txtsearch.Text
'If matching record found sets focus in str_Problem and shows msgbox
'and clears search control
If strProblemRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str_problem.SetFocus
txtsearch = ""
However my problem is that this is only searching for records where the text in "str_problem" matches the search criteria exactly so it will find a record with "printer" as the text in the "str_problem" field but not those which read "Printer is not working".
Any suggestions of how I can search on a single word within a bigger string?
Have a slight problem, I am trying to create a search form for an access database which searches for a word (or several words) within a string of text held in one of the tables rows.
The code I have so far is as follows;
DoCmd.ShowAllRecords
DoCmd.GoToControl ("str_Problem")
DoCmd.FindRecord Me!txtsearch
str_problem.SetFocus
strProblemRef = str_problem.Text
txtsearch.SetFocus
strSearch = txtsearch.Text
'If matching record found sets focus in str_Problem and shows msgbox
'and clears search control
If strProblemRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str_problem.SetFocus
txtsearch = ""
However my problem is that this is only searching for records where the text in "str_problem" matches the search criteria exactly so it will find a record with "printer" as the text in the "str_problem" field but not those which read "Printer is not working".
Any suggestions of how I can search on a single word within a bigger string?
Last edited: