How to work with data containing ' ?

E

eti

The ' mark is in the name of a person. When I tried to search the name (using
combo box), the below message appear....

Run-time error '3077':
Syntax error (missing operator) in expression.


Example Data (Name of person): Jo'tong Umbula

Thank you.
 
B

Banana

eti said:
The ' mark is in the name of a person. When I tried to search the name (using
combo box), the below message appear....

Run-time error '3077':
Syntax error (missing operator) in expression.


Example Data (Name of person): Jo'tong Umbula

Thank you.

This is a common problem for anyone working with any kind of SQL
databsae. You need to sanitize your strings before the little Bobby
Tables get to your database. ;) (but even if he did, it's OK- Access
doesn't support multiple statements so there's no chance of him dropping
your tables)

Few possible approaches:

1) Double up the apostrophe/quotation marks
2) Use a parameter query and insert into a parameter which always
handles this string
3) Strip it out and compare to the similarly stripped string from a
query (I'm not big fan of this approach)
 
J

John W. Vinson

The ' mark is in the name of a person. When I tried to search the name (using
combo box), the below message appear....

Run-time error '3077':
Syntax error (missing operator) in expression.


Example Data (Name of person): Jo'tong Umbula

Thank you.

Use " to delimit the name in your combo box's AfterUpdate event, rather than
'. If you would like help doing so, open the combo box in design view; view
its properties; and copy and paste the AfterUpdate event code to a message
here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top