Solved

SQL Database connect change in Access 2015

Posted on 2016-11-17
5
57 Views
Last Modified: 2016-12-27
Let me preface this.  I need to know why it is not working, not that its not suggested i do it this way.  This method of switching works best for my user group.

Access 2015.  SQLExpress 2014 (This is the dev environ).  Will be live on SQL Server 2014 Shared environ.  

2 buttons.  Both do versions of the following,  with the only difference being the "TEST" vs "LIVE" for glb_strLinkStatus

'Set desired connection status and corresponding ODBC Connect string
    glb_strLinkStatus = "TEST"
    Call SetConnectionString

'Loop through untill all tables are done
Do Until rs.EOF = True
    Set tdf = dbs.TableDefs(rs!Table_name)
    tdf.Connect = glb_strConnect
    tdf.RefreshLink
    rs.MoveNext
Loop

Open in new window


Associated Call:

Public Function SetConnectionString()
    'setup the glb_strConnect string to be the desired connection string;  If server location changes, update it here
    Select Case glb_strLinkStatus
        Case "UNLINKED"
            glb_strConnect = ""
        Case "LIVE"
            glb_strConnect = "ODBC;Description=PSF live database connection;DRIVER=SQL Server;" & _
                             "SERVER=MO631-6301QVV\SQLEXPRESS2014;Trusted_Connection=Yes;" & _
                             "APP=Microsoft® Windows® Operating System;Database=data"
        Case "TEST"
            glb_strConnect = "ODBC;Description=PSF test database connection; DRIVER=SQL Server;" & _
                             "SERVER=MO631-6301QVV\SQLEXPRESS2014;Trusted_Connection=Yes;" & _
                             "Microsoft® Windows® Operating System;Database=data_TEST"
        Case Else
            MsgBox "No Global Link status Found"
            Exit Function
    End Select
    
End Function

Open in new window


"LIVE" works.  "TEST" throws an error 3011, cannot find object "dbo_ENHProducers"  

Code for both is the same.  The "LIVE" and "TEST" databases are exact copies from the same backup.  

Similar issue when trying to link manually.

Associated table referenced in rs!Table_Name:

Tables
Any clue on the odd behavior?
0
Comment
Question by:Charlesdavid Allen
  • 2
5 Comments
 
LVL 35

Expert Comment

by:PatHartman
ID: 41892174
Is dbo_ENHProducers the name of a table/view that was used in the past but is no longer being used?  Try deleting all the linked tables.  Compact the database.  Then close and reopen Access and link the tables again.
0
 
LVL 1

Assisted Solution

by:Charlesdavid Allen
Charlesdavid Allen earned 0 total points
ID: 41892226
@Pat

dbo_ENHProducers is the name of the table/view that was used in the past, and it is still used.  The code is a method of switching between "TEST" and "LIVE" environments if the user has the appropriate level of authority to allow for financial environment testing.  

I tried your suggestion, no positive result (no change in previously seen result)

Played with Manual linking,  Found that the issue is with the driver used.  Changing to Driver=SQL Server Native Client 11.0; allowed connection to be applied appropriately.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 41892227
If the two strings are supposed to be identical except for the database name, then your second one does not have the "APP=" method qualifier.
0
 
LVL 1

Author Comment

by:Charlesdavid Allen
ID: 41892237
@Scott -  That is actually a viable solution as well.  

Please
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
trying to catch ODBC error when database opens 2 26
SQL Error - Query 6 24
sql server tables from access 18 17
ms sql + get number in list out of total 7 26
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

786 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