Solved

How do I read a field with an & in it for SQL

Posted on 2014-10-30
5
94 Views
Last Modified: 2014-11-04
Hello Everyone,

I have an access 2010 program that I am converting to work with the backend on the cloud.  On one form I have a listbox that when the user clicks on a line the system needs to find the record based on a client ID and client name.  Sadly some of the client names have & in them.  I am getting a parsing error because of the &.

Short of changing the & to and for all the clients is there a way using VBA to have it see the & as an &?

Thanks
0
Comment
Question by:alevin16
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 40414448
Try putting the field name in quotes.
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40414500
If you mean you are using SQL strings to query your backend try...

SELECT * from tblCompanies WHERE tnlCompanies.CompanyName like 'Benson \& Sons';

You need to replace all & with \& before your selects.
0
 

Accepted Solution

by:
alevin16 earned 0 total points
ID: 40414620
Hello All

Here is a snippet of the code.  on line 120 is where I put the value into a field.  Is there something I could do to the field in the text box?


120       cmd.Parameters("@txtemployeescompany").Value = [Forms]![MainForm2].[Form]![frmCurrent]![txtEmployeesCompany]
         
130       Set rst = cmd.Execute

140       If Not rst.EOF Then
150           Set rstClone = ut_MakeRS(rst)
160           ut_OpenAndFillRS rst, rstClone
0
 

Author Comment

by:alevin16
ID: 40414850
Hello everyone,

I found my error.  It was actually not a & but a / in the name.  In my program those are easy to remove and keep the people from putting them in again.

Thank you all!
0
 

Author Closing Comment

by:alevin16
ID: 40421164
I asked the wrong question actually
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

691 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