How do i insert a value taken from text box (object) on a form into a 'LIKE' Query in MS Access

StackOverflow https://stackoverflow.com/questions/23577116

  •  19-07-2023
  •  | 
  •  

Question

I am trying to build an update query in which once the user enters some text into a text box I have installed on a form, will then have a query (or perhaps loop) run so that all records in an underlying table which contain the value entered into the text box will be flagged.

At the moment my strategy is to take the value in the text box, paste it into a holding table (which I called tblSearchEngine07), and then run an my query which is aimed to identify all records where in the field called 'tblMasterListOfEventsNotes' the value pasted in my holding table will be referenced. Unfortunately, I am having a syntax issue and am not successfully getting the holding table value to be correctly inserted into my query.

This is my current query syntax:

SELECT tblSearchEngine01.tblMasterListOfEventsNotes
FROM tblSearchEngine01, tblSearchEngine07
WHERE (((tblSearchEngine01.tblMasterListOfEventsNotes) Like "*[tblsearchengine07].[parolachiave]*"));
Was it helpful?

Solution

Try to substitute your like with this:

like "*" & tblsearchengine07.parolachiave & "*"

Update.

If you are not interested in storing your search values in a table, you can simply create your query string by reading textBox.value like this:

Dim sql as string
sql = "update yourtablename set yourfiled = true where yourconditionfield like '*" & textboxname.value & "*'"
Docmd.runsql sql
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top