Solved

Like search using chr(34)

Posted on 2016-07-23
11
55 Views
Last Modified: 2016-07-24
Hi EE

I am having problems with a like search using chr(34)
Here is my code
Search = "SELECT * FROM tblCustomer WHERE [SurName] = " & Chr(34) & Me!txtSurname & Chr(34)
I want to change to a like search. I have tried
Search = "SELECT * FROM tblCustomer WHERE [SurName] Like " * [" & Chr(34) & "] * " &  Me!txtSurname & Chr(34)"

Any help appreciated

I need to use chr(34) because we have a lot of O'Brians etc

chestera
0
Comment
Question by:chestera
11 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 41726115
Try:
Search = "SELECT * FROM tblCustomer WHERE [SurName] Like * " & Chr(39) & " * " &  Me!txtSurname

Open in new window

0
 

Author Comment

by:chestera
ID: 41726184
MacroShadow

I tried
Search = "SELECT * FROM tblCustomer WHERE [SurName] Like * " & Chr(39) & " * " & Me!txtSurname

Get message missing operator, should there be something after me!txtsurname

Alan
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
ID: 41726191
the * need to be part of the string loke this

Search = "SELECT * FROM tblCustomer WHERE [SurName] Like  " & Chr(34) & "*" & Me!txtSurname & "*" & chr(34)
1
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 27

Accepted Solution

by:
MacroShadow earned 250 total points
ID: 41726197
Perhaps this:
Search = "SELECT * FROM tblCustomer WHERE [SurName] Like " & Chr(34) & Me!txtSurname & Chr(39) & "*" & Chr(34)
1
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 125 total points
ID: 41726229
Both of the following work.  For the latter I just used double quotation marks instead Chr(34).  Take your pick:
Search = "SELECT * FROM tblCustomer WHERE [SurName] LIKE " & Chr(34) & Me!txtSurname & Chr(34)
Search = "SELECT * FROM tblCustomer WHERE [SurName] LIKE """  & Me!txtSurname & """"

Open in new window


Ron
0
 

Author Comment

by:chestera
ID: 41726435
Macroshadow

Search = "SELECT * FROM tblCustomer WHERE [SurName] Like " & Chr(34) & Me!txtSurname & Chr(39) & "*" & Chr(34)

The above wont find any surname. I have for example I entered Jones which is a current surbname it didn't find it.

Alan
0
 

Author Comment

by:chestera
ID: 41726437
IrogSinta

Enter both
Search = "SELECT * FROM tblCustomer WHERE [SurName] LIKE " & Chr(34) & Me!txtSurname & Chr(34)
Search = "SELECT * FROM tblCustomer WHERE [SurName] LIKE """  & Me!txtSurname & """"

for example I searched for Jones and it finds all jones but if I enter Jon no luck

Your help is appreciated

Alan
0
 

Author Comment

by:chestera
ID: 41726440
Guy Hengel

Search = "SELECT * FROM tblCustomer WHERE [SurName] Like  " & Chr(39) & "*" & Me!txtSurname & "*" & chr(39)

It will find full name but not a partial name

Alan
0
 

Author Comment

by:chestera
ID: 41726449
Macroshadow

My Apologies. I must have a bug in the form I was using your code, I used another form an it worked.

I am going to ward point to all three in fairness. You was first so you get best solution.

Alan
0
 

Author Comment

by:chestera
ID: 41726450
IrogSinta

My Apologies. I must have a bug in the form I was using your code, I used another form an it worked.

I am going to ward point to all three in fairness
Alan
0
 

Author Comment

by:chestera
ID: 41726453
Guy Hengel

My Apologies. I must have a bug in the form I was using your code, I used another form an it worked.

I am going to ward point to all three in fairness. Alan
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question