?
Solved

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

Posted on 2014-10-30
5
Medium Priority
?
103 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

764 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