Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / February 2008

Tip: Looking for answers? Try searching our database.

Closing Delimiter error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AkAlan - 28 Feb 2008 19:17 GMT
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 & "'" & ")"
Sylvain Lafontaine - 28 Feb 2008 23:56 GMT
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.

Signature

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

> 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
[quoted text clipped - 10 lines]
> DateSchedCurrent & "','" _
>        & Comments & "','" & Me.TaskId & "','" & Me.txtPerfWc & "'" & ")"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.