Filter on string containg # in Access database through VB6

Hi Experts,
I am working on a desk top application with VB6 and Access database.
How can I  filter records containing "#"' in their string for Access? It does not return any records.My T SQL looks like:

If Trim(txtFltrDes) <> "" Then
     sSQL = sSQL & " AND Desc2 like  '" & Trim(txtFltrLoc) & "*'"
End If
         
     sSQL = sSQL & " Order By Address"
     Set rstdevs = db.OpenRecordset(sSQL, dbOpenDynaset)

It does not return any records if txtFltrDes text box has a string with # sign.
So I tried the following but no success!

If Trim(txtFltrDes) <> "" Then
          'sTempDesc = Replace(txtFltrDes.Text, "#", Chr$(35)) '
          i = InStr(1, txtFltrDes.Text, "#")
          If i > 0 Then
          sTempDesc = Left(txtFltrDes.Text, i - 1)
          sTempDesc = sTempDesc & Chr$(35) & Right(txtFltrDes.Text, Len(txtFltrDes.Text) - i)
         Else
           sTempDesc = txtFltrDes.Text
          End If
          'sSQL = sSQL & " AND Desc1 like  '" & Trim(txtFltrDes) & "*'"
           sSQL = sSQL & " AND Desc1 like  '" & sTempDesc & "*'"
     End If
     If Trim(txtFltrLoc) <> "" Then
          sSQL = sSQL & " AND Desc2 like  '" & Trim(txtFltrLoc) & "*'"
     End If
         
     sSQL = sSQL & " Order By Address"
     Set rstdevs = dbDevices.OpenRecordset(sSQL, dbOpenDynaset)
I read it somewhere that With # sign in a string, Access treats it like a numerical entry . Is there any way around it?
Any help will be greatly appreciated.
RekhaShahAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vaidhyanathan1Commented:
You need to give # as  [#]. Refer this url for more info. http://office.microsoft.com/en-us/access/HA011715361033.aspx
0
RekhaShahAuthor Commented:
Sorry, this was posted twice.  This has been resolved
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RekhaShahAuthor Commented:
CAn not use # as part of the string in Access95
0
vaidhyanathan1Commented:
You stated that it is a duplicate request, it will be good if you share the post id here. It will help viewers to know the details. Also you mentioned that we cannot use wild card character escape in access 95 and I verified the documentation, its not saying anything about wild card character restrictions.
0
RekhaShahAuthor Commented:
I have verified in my Dev environment.  I converted my Access95 database to later version(Access 2000). My logic worked fine. I plugged back the older database and it stopped working.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.