new PC and ODBC issues (1 Viewer)

theDBguy

I’m here to help
Joined
Oct 29, 2018
Messages
7,619
I get a debug on this line: If .Connect <> "" Then

"Object no longer set"
Hi. Try amending the code as such then:
Code:
Option Compare Database
Option Explicit

Public Const CONN_STRING As String = "Provider=SQLOLEDB.1;Integrated  Security=SSPI;Persist Security Info=False;Initial Catalog=GCDF_DB;Data  Source=BADLANDS"

Public Sub RelinkTable(TableName As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef

Set db = CurrentDb()
Set tdf = db.TableDefs(TableName)
With tdf
    If .Connect <> "" Then
        .Connect = CONN_STRING
        .RefreshLink
    End If
End With
Set tdf = Nothing
Set db = Nothing
End Sub
 

theDBguy

I’m here to help
Joined
Oct 29, 2018
Messages
7,619
This brings up the nagging window to enter a DSN name
I guess that tells me that connection string won't be a good one to use for a DSN-less connection. You'll need to try and get a good connection string from here.


PS. I just noticed your connection string has a DataSource argument, which is probably what is being used to specify the DSN.
 

kevlray

Registered User
Joined
Apr 5, 2010
Messages
727
Another thought why the connections might be 'missing'. Was your old machine OS 32-bit and your new machine 64-bit? If so creating new ODBC connections will use the 64-bit ODBC Data Source Administrator (unless you find and use the 32-bit ODBC Data Source Administrator). Of course that is probably irreverent if you are creating a connection in code.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom