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 6237545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:02:53+00:00 2026-05-24T11:02:53+00:00

I am trying to keep a copy of an activity table synchronized between a

  • 0

I am trying to keep a copy of an activity table synchronized between a SQL Server Express table and the production Access version. In other tables, I am able to wipe the contents of the SQL Server table, and insert the whole mess back in to capture all of the changes. However, when I attempt to do that with this table – I get the information – but the Autonumber field increments from the last unused number from the previous iteration. After a dozen or so ‘sync’ operations, I am dangerously close to running out of autonumbers for this field.

I have tried issuing the ‘DBCC CHECKIDENT’ from the Microsoft Access front end application, which throws an error that the statement didn’t start with SELECT, DELETE, PROCEDURE, DROP, ALTER or something like that. This command DOES work when issued from the SQL Server management console (a tool I do have access to in the current test environment, but will NOT when the application goes production).

I then tried the ‘TRUNCATE TABLE’ query using the DoCmd.RunSQL command and it threw the error that the operation isn’t supported on linked tables (approximately). This table is linked to the Microsoft Access front-end (the back end table is on SQL Server Express).

So, for a quick summary:

  • Front End is an Microsoft Access VBA application
  • Data is stored on SQL Server Express on a remote machine
  • Data tables are linked in the front end application
  • I will NOT be able to use SQL Server Management Console commands when this application goes production, it needs to run it’s housekeeping on it’s own.
  • DoCmd.RunSQL and CurrentDB.Execute do not seem to allow the use of the TRUNCATE TABLE -or- the ‘DBCC CHECKIDENT’ command.
  • Both of the aforementioned functions -DO- work when issued from the SQL Server Management Console – see above as to why this isn’t a viable option.
  • -ALL- other tables behave the way I’d expect them to besides this one, resetting their indentity fields as appropriate.

— Edited 08/08/2011 @ 15:08 —

Alright – I have tried a number of attempts at a VBA-based pass-through query, all resulting in an ODBC — call failed error. Here is the code for the module I created to handle pass-throughs (borrowed the code from dbforums.com):

Function RunPassThrough(ByVal ConnectionString As String, ByVal SQL As String, Optional ByVal QueryName As String)

    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef

    Set dbs = CurrentDb
    Set qdf = dbs.CreateQueryDef
    With qdf
        .Name = QueryName
        .Connect = ConnectionString
        .SQL = SQL
        .ReturnsRecords = (Len(QueryName) > 0)
        If .ReturnsRecords = False Then
            .Execute
        Else
            If Not IsNull(dbs.QueryDefs(QueryName).Name) Then dbs.QueryDefs.Delete QueryName
            dbs.QueryDefs.Append qdf
        End If
        .Close
    End With
    Set qdf = Nothing
    Set dbs = Nothing

End Function

As such, I need to specify a connection string to the database; all of the following have failed:

strConnect = "ODBC;DRIVER={SQL Server};SERVER=ENV980-067\ENVIRON_TEST;DATABASE=instkeeper_test;Uid=<my username>;Pwd=<my password>;"

Result: Run-time error ODBC — call failed (error #3146)

strConnect = "ODBC;DRIVER={SQL Server};SERVER=ENV980-067\ENVIRON_TEST;DATABASE=instkeeper_test;TRUSTED_CONNECTION=YES;"

Result: Run-time error ODBC — call failed (error #3146)

strConnect = "ODBC;DSN=instkeeper_beta;"

Result: Asks me for the Data Source Name, once specified with the Data Source administration panel, I get Run-time error ODBC — call failed (error #3146)

strConnect = "ODBC;Server=ENV980-067\ENVIRON_TEST;Database=instkeeper_test;User ID=<my user name>;Password=<my password>;Trusted_Connection=False;"

Result: Run-time error ODBC — call failed (error #3146)

— Edited 08/08/2011 @ 16:41 —

MORE failures on iterations of the connection strings, I am officially out of ideas on how to make this beast work. After trying the previous – now any pass-throughs made with the interface fail after asking for a DSN. No repair is possible, they have to be restored to call on the linked tables and ran through JET.

strConnect = "ODBC;DATA SOURCE=instkeeper_test;"

Result: Run-time error ODBC — call failed (error #3146)

strConnect = "ODBC;DRIVER=SQL Server;SERVER=ENV980-067\ENVIRON_TEST;"

Result: Run-time error ODBC — call failed (error #3146)

strConnect = "ODBC;DRIVER=SQL Server;Server=ENV980-067\ENVIRON_TEST;Database=instkeeper_test;User ID=<my user name>;Password=<my password>;"

Result: Run-time error ODBC — call failed (error #3146)

  • 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-05-24T11:02:55+00:00Added an answer on May 24, 2026 at 11:02 am

    I went through all of my code, and checked with a local VBA expert who pointed out that I had made an error in the naming of my tables while attempting to do a pass-through query. I, basically, was referring to the table by the name it possess as a link in my front-end, and not the actual table name it possesses in SQL Server on the back end.

    The following connection string, once this was corrected, worked:

    strConnect = "ODBC;DRIVER={SQL Server};SERVER=ENV980-067\ENVIRON_TEST;DATABASE=instkeeper_test;TRUSTED_CONNECTION=YES;"
    

    This, then, allowed me to execute the TRUNCATE TABLE command on the remote table, and execute a DoCmd.RunSQL statement to repopulate the table from the production source.

    The end result is that when the option is selected to update the Activity, it will purge the contents of the remote table, then read the contents of the production table into the test table for use while resetting the autonumber.

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

Sidebar

Related Questions

I have two versions of my app. I'm trying to keep a copy of
Trying to keep all the presentation stuff in the xhtml on this project and
I'm trying to keep dependencies to a minimum for a program I contribute to,
I have an alert script that I am trying to keep from spamming me
I'm creating a threaded message board and I'm trying to keep it simple. There's
I am trying to construct a way to keep certain hard drive partitions/usb drives
im trying to kick off a Runnable classes run method however i keep getting
I'm trying to do a simple erase and keep getting errors. Here is the
I'm trying to use the CRT memory leak detection but I keep getting the
I'm trying to use slime from CVS (2009-01-05) but keep getting this error: LOAD:

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.