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
 
Back
Top