Advertisement         >> Go to tutorial

vbWatchdog - Global Error Handler

Transform your VBA error handling.  vbWatchdog offers a robust mechanism for
catching and logging errors that occur in your VBA code on a global scale.

  • No DLLs required - vbWatchdog is coded neatly inside your VBA environment
  • Allows you to log the full callstack that lead up to the exception
  • Reports the values of variables within each procedure on the callstack
  • Offers a Try-Catch paradigm for simplifying local error handling
  • Prevents the Access Runtime from closing on unhandled errors
  • List the exact line number to identify the line of code that failed

Download the FREE Trial             Sample.MDB

 

Your VBA error dialogs could look like this:

vbWatchdog Error Dialog Example


Quotation marks within quotes

by Allen Browne, 30 June 2006
Applies to: Access 95+
User Level: Beginner
Views: 21,531
Rating: ***** (8 votes)
Comments: 0   Have your say...

Microsoft Access Tips for Casual Users

Provided by Allen Browne, June 2006.


Quotation marks within quotes

In Access, you use the double-quote character around literal text, such as the Control Source of a text box:
    ="This text is in quotes."

Often, you need quote marks inside quotes, e.g. when working with DLookup(). This article explains how.

Basics

You cannot just put quotes inside quotes like this:
    ="Here is a "word" in quotes"        ï Error!
Access reads as far as the quote before word, thinks that ends the string, and has no idea what to do with the remaining characters.

The convention is to double-up the quote character if it is embedded in a string:
    ="Here is a ""word"" in quotes"

It looks a bit odd at the end of a string, as the doubled-up quote character and the closing quote appear as 3 in a row:
    ="Here is a ""word"""

Summary:

Control Source property Result Explanation
="This is literal text."
This is literal text.
Literal text goes in quotes.
="Here is a "word" in quotes"

Error: The expression you entered contains invalid syntax

Access thinks the quote finishes before word, and does not know what to do with the remaining characters.
="Here is a ""word"" in quotes"
Here is a "word" in quotes
You must double-up the quote character inside quotes.
="Here is a ""word"""
Here is a "word"
The doubled-up quotes after word plus the closing quote gives you 3 in a row.

Expressions

Where this really matters is for expressions that involve quotes.

For example, in the Northwind database, you would look up the City in the Customers table where the CompanyName is "La maison d'Asie":
    =DLookup("City", "Customers", "CompanyName = ""La maison d'Asie""")

If you wanted to look up the city for the CompanyName in your form, you need to close the quote and concatenate that name into the string:
    =DLookup("City", "Customers", "CompanyName = """ & [CompanyName] & """")

The 3-in-a-row you already recognise. The 4-in-a-row gives you just a closing quote after the company name. As literal text, it goes in quotes, which accounts for the opening and closing text. And what is in quotes is just the quote character - which must be doubled up since it is in quotes.

As explained in the article on DLookup(), the quote delimiters apply only to Text type fields.

The single-quote character can be used in some contexts for quotes within quotes. However, we do not recommend that approach: it fails as soon as a name contains an apostrophe (like the CompanyName example above.)


Home Index of tips Top

Please Note: This is a cached tutorial (reproduced with permission).
To view the tutorial at its original location click here.



Rate this article:   Your rating: Poor Your rating: Not so good Your rating: Average Your rating: Good Your rating: Excellent

Have your say - comment on this article.

What did you think of 'Quotation marks within quotes'?

No comments yet.

Why not be the first to comment on this article?!

Have your say...

Name
E-mail (e-mail address will be kept private)
Comments
Verify Code
Verification Code
Please note: It may take 30 seconds after clicking submit - please be patient to avoid duplicate submissions.   All comments must be approved before being displayed on this web page.  This process may take up to 24 hours.


Site tools

SmartAccess
300+ articles.
Promo code EA-45K2D46TVS