Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 78
  • Last Modified:

SQL Database connect change in Access 2015

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
Charlesdavid Allen
Asked:
Charlesdavid Allen
  • 2
2 Solutions
 
PatHartmanCommented:
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
 
Charlesdavid AllenAuthor Commented:
@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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
Charlesdavid AllenAuthor Commented:
@Scott -  That is actually a viable solution as well.  

Please
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now