Solved

SQL Database connect change in Access 2015

Posted on 2016-11-17
5
30 Views
Last Modified: 2016-11-20
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
Comment Utility
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
Comment Utility
@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
Comment Utility
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
Comment Utility
@Scott -  That is actually a viable solution as well.  

Please
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

8 Experts available now in Live!

Get 1:1 Help Now