Number sign (#) in a string - FindFirst() doesn't work.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I'm using DAO 3.6 to find records in an access table and everything is fine,
but if i'm going to search for a string with a number sign (#) it doesn't
work.

e.g.
..FindFirst("[TOC] LIKE Cubes #2") 'doesn't work
and
..FindFirst("[TOC] LIKE Cubes 2") 'works.

Has anyone an idea what I could do to find "Cubes #2"?
 
Hi,
I'm using DAO 3.6 to find records in an access table and everything is fine,
but if i'm going to search for a string with a number sign (#) it doesn't
work.

e.g.
.FindFirst("[TOC] LIKE Cubes #2") 'doesn't work
and
.FindFirst("[TOC] LIKE Cubes 2") 'works.

Has anyone an idea what I could do to find "Cubes #2"?

Certain special characters must be surrounded with brackets.
Try:
.FindFirst("[TOC] LIKE Cubes [#]2")
 
fredg said:
Hi,
I'm using DAO 3.6 to find records in an access table and everything is fine,
but if i'm going to search for a string with a number sign (#) it doesn't
work.

e.g.
.FindFirst("[TOC] LIKE Cubes #2") 'doesn't work
and
.FindFirst("[TOC] LIKE Cubes 2") 'works.

Has anyone an idea what I could do to find "Cubes #2"?

Certain special characters must be surrounded with brackets.
Try:
.FindFirst("[TOC] LIKE Cubes [#]2")

Works perfect. Thank you!
 
When you are not using wildcards, use = as the operator instead of Like.
That should also solve this issue.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Phoenix said:
fredg said:
Hi,
I'm using DAO 3.6 to find records in an access table and everything is
fine,
but if i'm going to search for a string with a number sign (#) it
doesn't
work.

e.g.
.FindFirst("[TOC] LIKE Cubes #2") 'doesn't work
and
.FindFirst("[TOC] LIKE Cubes 2") 'works.

Has anyone an idea what I could do to find "Cubes #2"?

Certain special characters must be surrounded with brackets.
Try:
.FindFirst("[TOC] LIKE Cubes [#]2")

Works perfect. Thank you!
 
Thank you for your answer.
Unfortunally 'like' has a different meaning in each database.
I have now found a page in VB reference manual with a complete description
of the 'like' operator.
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaoprlike.asp)
The "=" operator probably is much faster. I will use it where ever possible.

Allen Browne said:
When you are not using wildcards, use = as the operator instead of Like.
That should also solve this issue.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Phoenix said:
fredg said:
On Fri, 2 Dec 2005 17:00:02 -0800, Phoenix wrote:

Hi,
I'm using DAO 3.6 to find records in an access table and everything is
fine,
but if i'm going to search for a string with a number sign (#) it
doesn't
work.

e.g.
.FindFirst("[TOC] LIKE Cubes #2") 'doesn't work
and
.FindFirst("[TOC] LIKE Cubes 2") 'works.

Has anyone an idea what I could do to find "Cubes #2"?

Certain special characters must be surrounded with brackets.
Try:
.FindFirst("[TOC] LIKE Cubes [#]2")

Works perfect. Thank you!
 
Phoenix said:
fredg said:
Hi,
I'm using DAO 3.6 to find records in an access table and everything is
fine,
but if i'm going to search for a string with a number sign (#) it
doesn't
work.

e.g.
.FindFirst("[TOC] LIKE Cubes #2") 'doesn't work
and
.FindFirst("[TOC] LIKE Cubes 2") 'works.

Has anyone an idea what I could do to find "Cubes #2"?

Certain special characters must be surrounded with brackets.
Try:
.FindFirst("[TOC] LIKE Cubes [#]2")

Works perfect. Thank you!

I don't see HOW it could work! You're obviously working with a string, so
the value needs to be enclosed in quotes.

As well, you don't need the parentheses:

..FindFirst "[TOC] LIKE 'Cubes [#]2'"
 
It was only an example. The original code is writen in Delphi. I'm not
familiar with Basic syntax. I only tried to make it more friendly to read for
VB-programmers, obviously with little success.

Douglas J. Steele said:
Phoenix said:
fredg said:
On Fri, 2 Dec 2005 17:00:02 -0800, Phoenix wrote:

Hi,
I'm using DAO 3.6 to find records in an access table and everything is
fine,
but if i'm going to search for a string with a number sign (#) it
doesn't
work.

e.g.
.FindFirst("[TOC] LIKE Cubes #2") 'doesn't work
and
.FindFirst("[TOC] LIKE Cubes 2") 'works.

Has anyone an idea what I could do to find "Cubes #2"?

Certain special characters must be surrounded with brackets.
Try:
.FindFirst("[TOC] LIKE Cubes [#]2")

Works perfect. Thank you!

I don't see HOW it could work! You're obviously working with a string, so
the value needs to be enclosed in quotes.

As well, you don't need the parentheses:

..FindFirst "[TOC] LIKE 'Cubes [#]2'"
 
Back
Top