Re: Closing Delimiter error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



When building a sql string, if you are using the single quote as the string
delimiter, then you must use double single quotes inside it; when it's
double quotes, you must use double double quotes. The situation is also
more complicated because the situation can repeat itself with the VBA
strings when you are using the double quotes for you sql string delimiters.

In your case, try replacing « Comments » with « Replace (Comments, "'",
"''") ». It's a good idea to display the result of strSql after that to
verify that everything is OK.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


"AkAlan via AccessMonster.com" <u18147@uwe> wrote in message
news:806b8c5b5e100@xxxxxx
Hi All, I am getting an error when there is an apostrophe in the Comments
text box. I tried using double double quotes in place of the single quotes
but get a different error then. Here is the code I use, thanks for any
help.


strSql = "INSERT INTO tblPmiHistory (PmiId,EquipId,Employee,StartDate,
FinishDate,DateSchedOriginal, " _
& " DateSchedCurrent,Comments,TaskId,PerfWc )" _
& " VALUES ('" & Me.PmiId & "','" & Me.EquipId & "','" &
Me.Employee
& "','" & Me.StartDate & "','" _
& Me.FinishDate & "','" & Me.DateSchedOriginal & "','" & Me.
DateSchedCurrent & "','" _
& Comments & "','" & Me.TaskId & "','" & Me.txtPerfWc & "'" & ")"

--
Message posted via http://www.accessmonster.com



.



Relevant Pages

  • Re: ComboBox Selection
    ... You will run into problems if your string contains the same character you ... are using as a delimiter. ... That's 2 single quotes, not one double quote. ...
    (microsoft.public.access.forms)
  • Re: SQL syntax: How to insert srting with double quotes?
    ... >> what quotes are delimiters, ... You need to fix ... >> each argument before you put it into the SQL string. ... I'm not saying one should always go with hungarian notation, in fact, I've ...
    (comp.databases.ms-access)
  • Re: Handling quotes in data entries
    ... You have the choice of using either single quotes or double quotes ... Since your string has double quotes in it, ... single quotes as the delimiter: ...
    (microsoft.public.access.modulesdaovba)
  • Re: Filter from Drop-Box
    ... Try putting the reference to the Quicklist control outside of the quotes ... that delimit the rest of the SQL string. ... Using a line continuation to split the line you would have: ...
    (microsoft.public.access.formscoding)
  • RE: SQL syntax in VBA for Access
    ... Turns out that the quotes around my dashes are what ... > is with the quotes in the SQL string. ... I'm trying to use vba to ... >> not getting the proper format. ...
    (microsoft.public.excel.programming)