Solved

Like search using chr(34)

Posted on 2016-07-23
11
50 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 142

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

778 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