B
Brian
Well, I'm a dunce. I just ran into what has to be one of the oldest problems
around, and while I have a couple ways of getting past it, I'm interested in
the best or most efficient way.
I was using Docmd.RunSQL to insert records but forgot that some names have
apostrophes in them.
BatchID being Long, CustomerName being String, and Amount being Currency:
Dim strSQL as String
'fields to insert
strSQL = "INSERT INTO MyTable(BatchID,CustomerName,Amount)"
'insert this data
strSQL = strSQL & " SELECT " & BatchID & ",'" & CustomerName & "'," & Amount
Docmd.RunSQL strSQL
Of course, it worked fine for the Smiths but choked on O'Donnell. (This is
in the middle of a long loop through a recordset, not just a single record.)
Should I:
1. Use a query & pass it the data as parameters?
2. Do a Replace (CustomerName,"'","")
Some more clever idea?
around, and while I have a couple ways of getting past it, I'm interested in
the best or most efficient way.
I was using Docmd.RunSQL to insert records but forgot that some names have
apostrophes in them.
BatchID being Long, CustomerName being String, and Amount being Currency:
Dim strSQL as String
'fields to insert
strSQL = "INSERT INTO MyTable(BatchID,CustomerName,Amount)"
'insert this data
strSQL = strSQL & " SELECT " & BatchID & ",'" & CustomerName & "'," & Amount
Docmd.RunSQL strSQL
Of course, it worked fine for the Smiths but choked on O'Donnell. (This is
in the middle of a long loop through a recordset, not just a single record.)
Should I:
1. Use a query & pass it the data as parameters?
2. Do a Replace (CustomerName,"'","")
Some more clever idea?