I run this function around ALL text fields on insert or update, it will fix your problem:
Function StoreText(theText)
StoreText = ""
on error resume next
StoreText = CStr(theText)
if (len(StoreText) > 0) Then
StoreText = Replace(StoreText, """", """, 1, -1, 1)
StoreText = Replace(StoreText, "'", "''", 1, -1, 1)
StoreText = Replace(StoreText, vbCrLf, "<BR>", 1, -1, 1)
end if
End Function
Use it like so:
strAdd = "INSERT INTO tblCompany SET CompanyName = '"& trim(storeText(CompanyName)) &"';"
objConn.Execute(strAdd)
FYI: running the trim function and using trailing semi colons are also very good habbits to get into
Wind is your friend
Matt
|