EscapeToSQL

Public Function EscapeToSQL(ByVal Expression As Variant) As String

Escapes a value (numeric, date/time, string, boolean, NULL) to a SQL expression representing this value. Dates are formated as SQL Server dates (t/d/ts)

Please note you can often also use the @"String" escaping to achieve the same result.

Public Function GetMyRecordSet(pContext, ByVal pTableName As String, ByVal pFieldName As String, pFilterValue As Variant) As RecordSet
   pTableName = CleanupString(pTableName, "-NAME-")
   pFieldName = CleanupString(pFieldName, "-NAME-")
   
   Dim lQuery As String = $"SELECT * FROM [{pTableName}] WHERE [{pTableName}].[{pFieldName}] = {EscapeToSQL(pFilterValue)}"
   
   Return pContext.OpenDynamicRecordSet(lQuery)
End Function