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

  • Home
  • SEARCH
  • 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 8186547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:14:46+00:00 2026-06-07T02:14:46+00:00

I’m using this code for an Access 2010 database, and I seem to have

  • 0

I’m using this code for an Access 2010 database, and I seem to have a problem with the syntax of my SQL statement, but I can’t for the life of me figure out how to correctly format the statement. Thank you in advance for any help!

qdf = db.CreateQueryDef("Company_State_Q")

Dim strSQLSearch As String


strSQLSearch = "SELECT [Company Information].Company_Name, " & _
"[Company Information].Industry" & _
"FROM Company Information" & _
"WHERE [Company Information].State ='" & stateV & "'" & _
"ORDER BY [Company Information].Company_Name;"



qdf.SQL = strSQLSearch
  • 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-07T02:14:47+00:00Added an answer on June 7, 2026 at 2:14 am

    You should use …

    Debug.Print strSQLSearch 
    

    … in your code after you build the strSQLSearch string. You can then view the string in the Immediate window (go there with Ctrl+g).

    From the Immediate window I set the value of stateV to “CA” and tested your string like this:

    stateV = "CA" : ? "SELECT [Company Information].Company_Name, " & _
    "[Company Information].Industry" & _
    "FROM Company Information" & _
    "WHERE [Company Information].State ='" & stateV & "'" & _
    "ORDER BY [Company Information].Company_Name;"
    SELECT [Company Information].Company_Name, [Company Information].IndustryFROM Company InformationWHERE [Company Information].State ='CA'ORDER BY [Company Information].Company_Name;
    

    Once you actually see the completed strSQLSearch string, it’s easy to spot multiple problems:

    1. IndustryFROM should be Industry FROM
    2. FROM Company Information should be FROM [Company Information]
    3. InformationWHERE should be Information WHERE
    4. 'CA'ORDER should be 'CA' ORDER

    Consider using line breaks between the sections of your SELECT statement. The db engine is perfectly happy with line breaks instead of spaces. And you may find it easier to read the statement as several short lines rather than as one long line.

    Dim strSQLSearch As String
    strSQLSearch = "SELECT ci.Company_Name, ci.Industry" & vbCrLf & _
        "FROM [Company Information] AS ci" & vbCrLf & _
        "WHERE ci.State ='" & stateV & "'" & vbCrLf & _
        "ORDER BY ci.Company_Name;"
    Debug.Print strSQLSearch
    

    Also at the beginning of your code you have …

    qdf = db.CreateQueryDef("Company_State_Q")
    

    It seems qdf must be a DAO.QueryDef object, so I think you should use the Set keyword to assign to it.

    Set qdf = db.CreateQueryDef("Company_State_Q")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to

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.