Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:03:38+00:00 2026-06-13T08:03:38+00:00

I have a database that collects client information using assessments and other tools. Often

  • 0

I have a database that collects client information using assessments and other tools. Often in the assessments there are double quotes in the data when – as may be expected – a direct quote is captured. When I run sql updates (Access front end using VBA to SQL Server 2008 R2 backend) it blows up on double quotes in the data. In the interim I’ve asked staff to use single quotes when they enter data, but that is an unsustainable solution as they forget and the program crashes when it hits the double quotes. The datatype is nvarchar(max).

The current VBA string looks like this:

strInsertSQL = “INSERT INTO tblIRPDetail(IRPID, SectionID, Challenge, Goal, Objective, Intervention, IntDate) VALUES(” & intNewID & “, ” & intSection & “, “”” & strChallenge & “””, “”” & strGoal & “””, “”” & strObjective & “””, “”” & strIntervention & “””, “”” & strIntDate & “””);”

Essentially any of the strVariables could have single or double quotes in any combination. It works for single quotes but not doubles. Surely this is a fairly common issue, I’m hoping someone has a simple solution!

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:03:39+00:00Added an answer on June 13, 2026 at 8:03 am

    An Access SQL statement can use either single or double quotes for text values. So you could use single quotes in your INSERT statement, but then you would run into a similar problem when the text to insert includes single quotes and which you could then resolve by doubling up the single quotes within the insert text:

    Replace(strChallenge, "'", "''")
    

    That doesn’t seem like much of an improvement. OTOH, since you’re using VBA to insert a row to your table, you don’t need to use an INSERT query.

    Open your table as a DAO.Recordset, add a new row, then assign your variable values to the corresponding fields.

    Public Sub NPO_AddRow()
        Dim db As DAO.Database
        Dim rs As DAO.Recordset
    
        Set db = CurrentDb
        Set rs = db.OpenRecordset("tblIRPDetail", dbOpenTable, dbAppendOnly)
        With rs
            .AddNew
            !IRPID = intNewID
            !SectionID = intSection
            !Challenge = strChallenge
            !Goal = strGoal
            !Objective = strObjective
            !Intervention = strIntervention
            !IntDate = strIntDate
            .Update
            .Close
        End With
        Set rs = Nothing
        Set db = Nothing
    End Sub
    

    Note that, unlike a parameter query, this approach will allow you to add text strings longer than 255 characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my database that collects info at regular intervals. There
I have a UITableView that collects data from a database. What I would like
I have a server that collects a lot of information. Right now there is
Is there anyway to have a client side small database that syncs with server
I currently have an Entity Framework model that collects data from a legacy database
I have a Database that contains data about articles , structures and manufacturers .
I have a database that I have created using SQL Server Developer 2008. I
I have a device that continuously collects data and stores it on a local
I have been asked to develop a system that collects data from a Sql
Here's my scenario: I have one page that collects certain data from the user.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.