Hello-
I am trying to pull data from the database on our server using a SQL Select statement. The criteria is a string value that is input on a user form, and the results populate a list box. Simple enough. Here's a bit of my code:
Everything works just fine until the user attempts to search for a string that includes an apostrophe. Then , of course, it confuses the SQL statement. Any ideas on how to solve this?
Thanks!
I am trying to pull data from the database on our server using a SQL Select statement. The criteria is a string value that is input on a user form, and the results populate a list box. Simple enough. Here's a bit of my code:
Code:
Set objConn = CreateObject("ADODB.Connection")
objConn.Open strConnect
strSQL = "SELECT acctno, name, city, country FROM CustomerVendor WHERE Name LIKE '" & strAgent & "%'"
Set objRS = objConn.Execute(strSQL)
Thanks!