Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Database connect change in Access 2015

Posted on 2016-11-17
5
Medium Priority
?
75 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 39

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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

704 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