Coding around apostrophe's (Error Number: 3075)

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

Hi all - I have a VBA code that generates the following
expression: (((ContactLastName & ','& ContactFirstName)
= 'Smith,Max')). Everything works perfectly until I run
into an O'Shea or O'Neal where the apostrophe in the name
unbalances the formula.

Is there a preferred way to code around this, or do I have
to create an error trapping routine to work around the
problem?

Thanks for your help!

Rick
 
Try doubling the apostrophe as in O''Neal. When you want
to display characters as text that otherwise have special
functions in Access, you have to double them in the text
string. This often comes up when you want to display
something like "A&B" - you have to enter it as "A&&B"
Hope this helps.
 
Hi all - I have a VBA code that generates the following
expression: (((ContactLastName & ','& ContactFirstName)
= 'Smith,Max')). Everything works perfectly until I run
into an O'Shea or O'Neal where the apostrophe in the name
unbalances the formula.

In addition to the suggestion of doubling the apostrophe, note that
you can and usually should delimit strings with " instead of ':

ContactLastName & ", " & ContactFirstName
 
John & Anonymous - Thanks for the suggestions. I'll give
these a try!

Rick
 

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

Back
Top