Solved

SQL Database connect change in Access 2015

Posted on 2016-11-17
5
49 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:C Allen
  • 2
5 Comments
 
LVL 34

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:C Allen
C 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:C Allen
ID: 41892237
@Scott -  That is actually a viable solution as well.  

Please
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now