[AccessD] Filter text containing ampersand requires apostrophes?

Arthur Fuller fuller.artful at gmail.com
Wed Jun 22 05:57:18 CDT 2011


Here are two simple functions that I use in such situations, primarily
because they make the code easier to read:

<vba>
Public Function q(str As String) As String    'wrap an element in single
quotes
    q = Chr(39) & str & Chr(39)
End Function

Public Function qq(str As String) As String   'wrap an element in double
quotes
    qq = Chr(34) & str & Chr(34)
End Function
</vba>

HTH,
Arthur

On Tue, Jun 21, 2011 at 9:49 PM, William Benson (VBACreations.Com) <
vbacreations at gmail.com> wrote:

> When I needed to filter a datasheet subform on a certain field, I ran into
> a
> case where the text filter had an ampersand
>    Florida Power & Light Company
>
> Access refused to find the record when I entered exactly that in the text
> box that comes up when I choose the Equals... menu from the right-click,
> until I put apostrophes around it.
>
> I cannot understand why the Access interface requires apostrophe -- just
> because there is an ampersand in the midst of the string.
>
> I don't think users who are not programmers are going to know about that,
> will they? More likely to conclude the field value is absent?
>
>



More information about the AccessD mailing list