473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with apostrophe

Hi all,

I apologize if not posting correctly, my first time.
I am having problem with the field "Scheduled" (7901-D'Acunha-A-5) getting:
" Syntax error (missing operator) in query expression "7901-D'Acunha-A-5', " , 'Done', 'Update', #4/6/2009 2:21:17 PM#)'

I know is related to the apostrophe and I searched and found results on (single quotes), I tried to make changes myself, with no luck.

I wasn't sure how much I should post.
==========================================
Expand|Select|Wrap|Line Numbers
  1. Function build_sql(Schedule_ID As Date, operation As String) As String
  2.      build_sql = "Insert Into tblJobScheduleAuditLog ([ScheduleID],[Scheduled], [JobDate], [Status],[Action],[Timestamp]) Values (#"
  3.      build_sql = build_sql & ScheduleID & "# , "
  4.      build_sql = build_sql & "'" & _
  5. DLookup("Scheduled", "JobSchedule", "ScheduleID=#" & _
  6. Schedule_ID & "#") & "', "
  7.      build_sql = build_sql & "'" & _
  8. DLookup("JobDate", "JobSchedule", "ScheduleID=#" & _
  9. Schedule_ID & "#") & "', "
  10.       build_sql = build_sql & "'" & _
  11. DLookup("Status", "JobSchedule", "ScheduleID=#" & _
  12. Schedule_ID & "#") & "', "
  13. build_sql = build_sql & "'" & operation & "', "
  14.      build_sql = build_sql & "#" & Now() & "#)"
  15.    End Function
===========================================

Thanks for any help in advance,
Emilio
Apr 6 '09 #1
3 1924
ChipR
1,287 Expert 1GB
You're right, you won't be able to surround a text field that contains apostrophes with apostrophes. The solution is to surround the data with quotes instead. Try:
Expand|Select|Wrap|Line Numbers
  1. build_sql = build_sql & """" & DLookup(...) & """"
The double " gets turned into a single " in the resulting string.
Apr 6 '09 #2
@ChipR
Thank you very much!

Great fast help

Emilio
Apr 6 '09 #3
NeoPa
32,556 Expert Mod 16PB
An alternative (that is consistent with the SQL standards) is to provide a function to double up any single quotes (not actually apostrophes, but often treated the same) within your data.

In VBA it's fairly straightforward, as the Replace() function is already available.
Expand|Select|Wrap|Line Numbers
  1. ...
  2. Build_SQL = Build_SQL & "'" & Replace(YourValue, "'", "''") & "'"
  3. ...
Apr 6 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jeremy | last post by:
Hi, I have a webpage that is taking input from a form and using it as criteria to select data out of an sql database. The page displays an html table with the results. The user can then click a...
2
by: CSDunn | last post by:
Hello, I have a combo box designed to look up records in a subform based on the selection made in the combo box. The Record Source for the combo box is a SQL Server 2000 View. There is one bound...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
13
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices...
1
by: congngo | last post by:
Hi all Every time I export a table into an excel spreadsheet. It has a leading apostrophe on every cells. This drive me nut. I have to do a work around by export table into a txt file than...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
1
by: karen987 | last post by:
I have an ASP news page to which you can add comments. The comments open up in a new window, and users can click reply to reply to them after which they are taken to the parent page which has a...
6
by: pabloski | last post by:
Hi to all, I have a little problem with unicode handling under Python. I have this code s = u'A unicode string with this damn apostrophe \x2019' outf = codecs.open('filename.txt', 'w',...
5
by: =?Utf-8?B?TEtOZXdzR3JvdXBz?= | last post by:
Hi I have a list which pulls out items from a stored procedure. Unfortunately some of the items it pulls out have apostrophes. This info need to be placed in a URL but it keeps truncating at the...
9
by: Thomas 'PointedEars' Lahn | last post by:
Jukka K. Korpela wrote: IBTD. For example, in English it is customary (and AIUI expected) to use the character that ’ represents should be used to delimit a quotation within direct speech...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.