Hi Nam
Code snip from working system may help.
Table is deleted and reattached which will make visible any changes in
SQL2000 table structure, otherwise any changes made to backend tables will
not be visble in Access
You will need to setup your own connection string (cS)
Need to pass in Table name and alias thus
Call RecreateConnection("tblLogData", "tblLogData")
Cheers
Ian B
~~~~~~~~~~~~~~~~~~~~~~
Private Sub RecreateConnection(sTableName As String, sTableAlias As String)
On Error GoTo RecreateConnection_Err
100: Call Initialise
110: Dim cS As String
120: Dim dbs As Database
130: Dim tdf As TableDef
140: On Error Resume Next ' IN CASE TABLE IS UNLINKED
150: DoCmd.DeleteObject acTable, sTableAlias
160: On Error GoTo RecreateConnection_Err
170: cS = "ODBC;driver={SQL Server};server=" & sSQLServer & ";database=" &
sSQLDBase & ";Trusted_Connection=Yes;TABLE= " & sTableName & "'"
190: Set dbs = CurrentDb
200: Set tdf = dbs.CreateTableDef(sTableAlias)
210: tdf.Connect = cS
220: tdf.SourceTableName = sTableName
230: dbs.TableDefs.Append tdf
240: dbs.TableDefs.Refresh
250: dbs.Close
RecreateConnection_Exit:
Exit Sub
RecreateConnection_Err:
Dim strErrString As String
strErrString = "Error Information..." & vbCrLf
strErrString = strErrString & "Error#: " & Err.Number & vbCrLf
strErrString = strErrString & "Line#: " & Erl() & vbCrLf
strErrString = strErrString & "Error Description: " & vbCrLf &
Err.Description
MsgBox strErrString, vbCritical + vbOKOnly, "Function:
RecreateConnection"
Resume RecreateConnection_Exit
End Sub