Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query problem

Status
Not open for further replies.

Gaylord

Technical User
Sep 26, 2002
49
0
0
DE
Hi,

I am trying to insert the following into a table, which is working fine.....

Update = "INSERT INTO TEMP (ID, POLLING_NUMBER, NAME) "
Update = Update & "VALUES (" & curRecord & ", " & rt.Fields("POLLING_NUMBER").Value & ", '" & formatName & "');"

But when I try and insert an individual called John De'ath, the "'" causes the query to fail and throws up an error.... Am I missing something. I have tried square brackets around the query, but after that I have run out of ideas....

Can anyone suggest how to get around this (without removing the apostrophy).

Thanks in advance

Jamie
 
I think the below should work:

ADO and DAO:
[tt]...& ", '" & replace(formatName,"'","''") & "');"[/tt]

Only DAO i think:
[tt]...& ", """ & formatName & """);"[/tt]

Roy-Vidar
 
That's great! Thanks so much for that. Was luck that I spotted it.. Quite an unusual name, but better done now.

Cheers

Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top