What is wrong with this sql

LO 7.1.12 Windows 10 64 bit
Link to full Database file (Link IMAGES.odt) with 3 sample datafolders and tables and all macros.

FULL DATABASE FILE IN A ZIP

I have a macro that I am using to populate a list box based on the content of another textbox on the form. the macro should return a list of cities in a country and let the user choose one. Here is the relevant code.

sSQL = "SELECT DISTINCT ""city"" FROM ""worldcities"" WHERE ""country ="" " + oCountryBox.text
	Resultset = Statement.executeQuery(sSQL)

If you need the full macro please look in the zip file. I can not understand how to use the pre and code button on this forum. Every time I push that button and past in code only the first line gets put in the code box the rest comes to the forum as an unformatted jumble of code. In anycase back to my question.
I am getting a sql error dialog box popping up saying:

image description

But I have checked the worldcities table and the spelling is correct and the column is populated. I am assuming this is a sql syntax error but I cannot see where it is.

Thanks in advance

Hello,

Without looking at the full code & only at the SQL, the error indicates the problem. It is referring to country = and seems you have misplaced the = sign.

Try:

sSQL = "SELECT DISTINCT ""city"" FROM ""worldcities"" WHERE ""country"" = " & oCountryBox.text
Resultset = Statement.executeQuery(sSQL)

Note:

I prefer & over +.