String Syntax

  • Thread starter Thread starter Newbie
  • Start date Start date
N

Newbie

I have form that we I click a button it goes off to SQL Server and creates a
recordset. The records that are in the recordset I want to input into a
local table to run reports against

I use the following string and then loop through the records (see below)
which works fine except when there is a ' (single apostrophe) in the name.

How can I get round this problem?
The offending fields are:
rsCommission.Fields(1) and rsCommission.Fields(8)

Thanks
strQuery = "INSERT INTO SalesCommission Values('" &
rsCommission.Fields(0) & "', '" & rsCommission.Fields(1) & "', '" &
rsCommission.Fields(2) & "', " & rsCommission.Fields(3) & "," &
rsCommission.Fields(4) & ", " & rsCommission.Fields(5) & "," &
rsCommission.Fields(6) & ", " & rsCommission.Fields(7) & ", '" &
rsCommission.Fields(8) & "')"
 
Hi,
Use the Replace function to double up the occurences of single quotes so that the
string will become:
Dan O''Neil

Replace(rsCommission.Fields(1),"'","''")
 
Thanks
Dan Artuso said:
Hi,
Use the Replace function to double up the occurences of single quotes so
that the
string will become:
Dan O''Neil

Replace(rsCommission.Fields(1),"'","''")
 
Back
Top