dreamdelerium
Registered User.
- Local time
- Today, 10:40
- Joined
- Aug 24, 2007
- Messages
- 88
hi everyone. when i send an sql statement to update a table or add a record i am using the replace function [ie, replace (something, "'", "''")] to remove all single quotes from my string. are there other characters i need to remove as well that might cause problems? here is an example of my insert strings:
i know it looks a bit screwed up but this was the fastest way to create an insert sql statement with 187 inserts. thanks for the help
jason
Code:
For i = 0 To 186
InsertString = InsertString & "Q" & Format(i, "000") & ","
Next i
GetLength = Len(InsertString) - 1
InsertString = Left(InsertString, GetLength)
For i = 0 To 186
InsertString1 = InsertString1 & Replace(Forms![frmSection1].Controls("Q" & Format(i, "000")).Value, "'", "''") & "','"
Next i
GetLength = Len(InsertString1) - 1
InsertString1 = Left(InsertString1, GetLength)
MyNewString = "Insert into tblSection1 (QuestionaireID,DistrictID,FacilityID,SectionID,StudyID," & InsertString & ") " _
& "values ('" & q1 & "','" & GetDistrict & "','" & GetFacility & "','1','" & GetCode & "','" & InsertString1 & ")"
GetLength = Len(MyNewString) - 2
MyNewString = Left(MyNewString, GetLength)
MyNewString = MyNewString & ")"
MyNewString = MyNewString
buildMyStringForm1 = MyNewString
i know it looks a bit screwed up but this was the fastest way to create an insert sql statement with 187 inserts. thanks for the help
jason