View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
onedaywhen onedaywhen is offline
external usenet poster
 
Posts: 459
Default SQL string problem

"Jake Marx" ...

Public Function gsMakeStringSQLSafe(rsSQL As String) As String
gsMakeStringSQLSafe=Replace$(rsSQL, "'", "''")
End Function

Just pass your SQL statement through this function when opening your
recordset


Your function rendered my SQL statement as:

SELECT RefID
FROM PersonalDetails
WHERE Surname = ''Cruise''

which gives the error, "Incorrect syntax near 'Cruise'".

--