[AccessD] Preventing Extra Excel instances SOLVED

Arthur Fuller artful at rogers.com
Fri Oct 28 14:25:45 CDT 2005

JC, perhaps my solution will work for you. I use a pair of functions that I
call q() and qq(), which stand for single and double quotes. 
Public Function q(str As String) As String
    q = Chr(39) & str & Chr(39)
End Function

Public Function qq(str As String) As String
    q = Chr(34) & str & Chr(34)
End Function
Then for any column that may contain an apostrophe, you can just write 
SELECT q(ColumName) from MyTable
Without even bothering to check whether there are apostrophes. You just stop
worrying about it.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Colby
Sent: October 26, 2005 8:18 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Preventing Extra Excel instances SOLVED

I had one today...

I build a SQL statement as the recordsource for a form.  I am dynamically
building up a where clause where I substitute in the field name and value in
the where clause.  A name ( O'Doule or some such) has an apostrophe in it.
As you know, the ' is the syntax for enclosing text strings in a SQL
statement when doing this.... 

	"Some SELECT HERE" & _
	"WHERE SomeField = '" & strSomeValue & "';"

In many of the computers at the client, when I append the SQL string in the
form's recordsource with an ' in the middle, instead of a run time error,
Access gives a warning and shuts down.  On my machine it correctly gives a
runtime error.

I am SOOOOooooo tired of this buggy program.

John W. Colby

Contribute your unused CPU cycles to a good cause:

More information about the AccessD mailing list