I am linking Access tables to SQL server using the following code:
Code:
mblnErrorOccurred = False
If Right$(strDSN, 4) = "Test" Then
strDatabase = "VBackendTest"
Else
strDatabase = "VBackend"
End If
intNumTables = VOREGdb.TableDefs.Count
varReturn = SysCmd(acSysCmdInitMeter, "Relinking Tables", intNumTables)
intI = 0
For Each tdf In VOREGdb.TableDefs
If Len(tdf.Connect) > 0 Then
strNewConnectString = "ODBC;DSN="
strNewConnectString = strNewConnectString & strDSN
strNewConnectString = strNewConnectString & ";UID=" & strUID & ";APP=Microsoft® Access;DATABASE=" & strDatabase & ";Network=DBMSSOCN;Password=test;Trusted_Connection=NO"
tdf.Connect = strNewConnectString
On Error Resume Next
tdf.RefreshLink
If Err.Number <> 0 Then
mblnErrorOccurred = True
mstrErrorMessage = Err.Description
varReturn = SysCmd(acSysCmdRemoveMeter)
GoTo Exit_Proc
End If
End If
intI = intI + 1
varReturn = SysCmd(acSysCmdUpdateMeter, intI)
[\code]
This links the tables fine, but the first table causes the SQL Server DSN dialog box to display. The dialog box has the DSN name I provided in the connect string already filled in, but the password must be provided again even though I have provided that in the connect string as well.
Is there any way to stop the dialog box from dispaying?
Any help would be greatly appreciated.
Phil