Results 1 to 6 of 6
  1. #1
    alfred.lok is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Aug 2022
    Posts
    3

    Converting ADP to ACCDB: forms / reports controls record source - Syntax error in query.

    My client is using an old Access ADP file and has to upgrade to Access 2016 due to corporate policy.

    The old ADP files:
    1. Connect to a SQL Server
    2. With lots of forms / reports etc.

    My understanding:
    1. Use Access 2010 to create a blank database
    2. Create linked tables to the SQL Server: I write a VBA function (DSN less) to link to the SQL server as I do not want to use DSN. I want to distribute the files easily. It is completed.
    3. Import the forms, reports, modules and macro.

    The conversion, certainly has many issues that I need to fix.

    In the old ADP files, the forms / reports controls record source: the strings are encapsulated eg.


    Code:
    select `sometable`.`somefield` from `sometable`
    It creates error:
    Syntax error in query. Incomplete query clause.


    I need to change that to in order to remove the error:
    Code:
    select sometable.somefield from sometable
    It is impossible for me to remove the encapsulating quote for every controls.

    May I know:
    1. Is there a way to remove the encapsulation quickly? Or
    2. Why Access 2010 does not support that? Is that a way to enable it?
    3. When the ACCDB is delivered to the client, will Access 2016 require to include back the encapsulation?

    Thanks.

    Alfred

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    By encapsulation you mean words in the code or sql are wrapped/delimited with single quotes then yes you could remove them using code. Whether or not this would be worth the effort would depend on the volume/scope of the job. Removing from sql statements: not too hard. Removing from code: more of a problem. The stumbling block might be that if these quotes are contained in expressions used as data sources for controls on forms and reports, that could be a problem. So where are all of these code snippets?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    alfred.lok is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Aug 2022
    Posts
    3
    1. Encapsulation: yes. The table names and field names are delimited by a quote.
    2. There are over 100 forms/reports. Each forms has lots of combo box etc. and there are a lot of textboxes etc. in the header, details, footer sections etc. of a report
    eg. in a combo box of a form, the row source:
    Code:
    select `person`.`lastname' from 'person' where ...
    There may have some join queries, certainly.

    My first investigation, those queries are not found in the code file.

    I think the error is due to
    1. ADP is directly linked to SQL server. SQL server knows it.
    2. ACCDB uses ODBC and ODBC simply does not support. Is there any options to turn on this?

    Thanks.

    Alfred

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I've never worked in an adp so can't shed much light on that. As for ODBC to me it was always that Open Data Base Connectivity was just a tool/driver I used to connect to sql server databases so not sure if the issue with the quotes is ODBC or if it's the client server. I would have thought it was the latter. Not sure what to tell you what to do about the issue, short of removing all the quotes so let's see if you get any better ideas. As I said, not too hard to remove characters from sql. More intensive to do so with code and IMO, harder still for removing from control record source properties. It sounds like that is where the bulk of the problem lies. You did give an example of where they are, but didn't clarify if that is the only place they're used.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    select `person`.`lastname' from 'person' where ...
    for code like this you can remove the encapsulation, but if table or feild names contain spaces or non alphanumeric characters (except the underscore) then they need to be replaced with square brackets.

    So for sql code, I would look to replace rather than remove

    You can write something that loops through every control of every form looking for list and combo boxes to update the appropriate sql

    But sounds to me your ADP has not 'upsized' properly. Does the encapsulation exist in the original file? If not, review how you are moving it to 2010

  6. #6
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,035
    I used to work with ADP files some 20 years ago, and they are connected directly to the SQL server. So, SQL statements in code ect. are directly parsed, evaluated and executed by the SQL engine. T-SQL differs from access SQL in several places (example in joins), and has a lot of options access sql doesn't have, so I'm afraid you'll also have to check the SQL syntax.

    Standard table and fieldnames are encapsulated in double quotes "Name" or brackets [Name], and a single quote ' is used to delimit 'text strings'. Maybe this was wrongly translated in the convertion and the double quote became a single.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 18
    Last Post: 02-22-2021, 05:25 PM
  2. Redefine location of source of a ACCDB query
    By Jazz Engineer in forum Queries
    Replies: 8
    Last Post: 01-09-2021, 08:57 PM
  3. Syntax error in control source of text box
    By shaunacol in forum Forms
    Replies: 7
    Last Post: 07-16-2015, 04:55 AM
  4. Replies: 1
    Last Post: 01-22-2013, 02:01 PM
  5. Replies: 1
    Last Post: 06-24-2011, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums