Annie Courchesne, CMA
accma at sympatico.ca
Fri Apr 17 05:26:34 CDT 2009
Arthur,
I'll try that too! Thanks!
Annie
-----Message d'origine-----
De : accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] De la part de Arthur Fuller
Envoyé : 16 avril 2009 23:34
À : Access Developers discussion and problem solving
Objet : Re: [AccessD] Text problem in runSQL
Wrap your strings in the following function:
<vba>
Public Function q(str As String) As String
q = Chr(39) & str & Chr(39)
End Function
</vba>
IOW, instead of refering a string head-on, which may contain quotes, use
q(FieldName) instead. Depending on circumstances, you may also need:
<vba>
Public Function qq(str As String) As String
qq = Chr(34) & str & Chr(34)
End Function
</vba>
Just wrap your column refs in a call to these functions instead of direct
references and you're guaranteed safety (from these boogers at least).
e.g.
Debug.Print q("Patty O'Furniture")
--> 'Patty O'Furniture'
hth,
Arthur
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com