473,387 Members | 1,548 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,387 software developers and data experts.

syntax error message for names with apostrophe

Hi,

i'm getting syntax error message for this button that tries to get name (of building) with apostrophe. Any idea how to solve this? Note that i must use name with apostrophe e.g. O'neal:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command76_Click()
  2. On Error GoTo Err_Command76_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = ChrW(1506) & ChrW(1491) & ChrW(1499) & ChrW(1503) & ChrW(32) & ChrW(1508) & ChrW(1512) & ChrW(1496) & ChrW(1497) & ChrW(32) & ChrW(1502) & ChrW(1489) & ChrW(1504) & ChrW(1492)
  8.  
  9.     stLinkCriteria = "[Building]=" & "'" & Me![Building] & "'"
  10.     DoCmd.OpenForm stDocName, , , stLinkCriteria
May 4 '10 #1

✓ answered by MikeTheBike

@inbarik
Hi

You could try ths

stLinkCriteria = "[Building]=" & "'" & Replace(Me![Building],"'","''") & "'"

This will replace all occurrences of a single apostrophe in the Building string with 2 apostophes.

The interpreter will then assume you want to have a (single) apostrophe in the string and that it is not the end of variable delimiter.

HTH


MTB

1 2692
MikeTheBike
639 Expert 512MB
@inbarik
Hi

You could try ths

stLinkCriteria = "[Building]=" & "'" & Replace(Me![Building],"'","''") & "'"

This will replace all occurrences of a single apostrophe in the Building string with 2 apostophes.

The interpreter will then assume you want to have a (single) apostrophe in the string and that it is not the end of variable delimiter.

HTH


MTB
May 4 '10 #2

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

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
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,...
1
by: Ronny Sigo | last post by:
Hello all, I have made a form containing a combox which must look up values (names) in a table. It works fine until the moment I try to put in a name containg an apostrophe. (e.g. d'Haen). At this...
5
by: Berend | last post by:
when I try to write to a database I get a syntax error I made the code a simple as possible bur also the VS generated code gives the same error. WHY? private void button1_Click(object sender,...
3
by: brianbasquille | last post by:
Hello all, Strange little problem here... am just trying to insert some basic information into an Access Database using OleDB. I'm getting a "Syntax error in Insert Into statement" when it...
9
by: VancouverMike | last post by:
Hi there, I run into a very strange problem. I got the following url and am passing information via query string. The problem when the "sin" key in query string is blank, shown as in the...
4
Tog
by: Tog | last post by:
Hello, I have read several posts with this heading but none of them have helped. I have the following error message: Syntax error (missing operator) in query expression 'left(Your Product...
0
by: snowdream1982 | last post by:
Dear all, I hit an error OVERFLOW but when I insert the sql statement below manually in the SQLEditor, it goes well, no errors at all. My coding: SQLInsertTempMf = "INSERT INTO tempmf " &...
14
by: Eliot | last post by:
I have a project which may be compiled with some #defines. Say:- #define firstdef #define seconddef If no defines are present or only one is present all is OK. I would like to add a self...
7
by: HSXWillH | last post by:
I have a field in a database that contains last names. In some of those names, like O'Brien and O'Connor, there is a ' symbol. I am using combo boxes on a form to build a form filter and in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.