I am trying to refresh table links at startup in an Access 2002 application. The following code is based on a number of articles posted in this group but this does not seem to work:
===CODE SNIPPET START=== For i = 0 To CurrentDb.TableDefs.Count - 1
If Left(CurrentDb.TableDefs(i).NAME, 3) = "tbl" Then
<colin.anderson@justice.vic.gov.au> a йcrit dans le message de news: 1118113394.871278.122380@g47g2000cwa.googlegroups.com...> Hi>
I am trying to refresh table links at startup in an Access 2002> application. The following code is based on a number of articles> posted in this group but this does not seem to work:>
===CODE SNIPPET START===> For i = 0 To CurrentDb.TableDefs.Count - 1>
If Left(CurrentDb.TableDefs(i).NAME, 3) = "tbl" Then>
constODBC_ConnectString is a global string variable containing a valid> connect string.>
No errors are generated but the Connect property does not get updated> in either case. The original (manually linked) connect property is> maintained.>
I use the following code, which deletes the existing tabledefs and creates/appends new ones.
Bill E. Hollywood, FL ------------------------------------------------------------- Public Const strConnect= "Set your connection string here"
Function SetConnections() On Error GoTo Trapper Dim strTableName, strSourceTableName As String Dim objTableDef As TableDef
'Reset the connection property for all pass through queries For Each QueryDef In CurrentDb.QueryDefs If QueryDef.Connect <> "" Then QueryDef.Connect = "ODBC;" & strConnect End If Next
'Reset connections for linked tables For Each TableDef In CurrentDb.TableDefs If TableDef.Connect <> "" Then 'Get the table name and source table name strTableName = TableDef.Name strSourceTableName = TableDef.SourceTableName
'Recreate the tabledef Set objTableDef = New TableDef With objTableDef .Name = strTableName & "Temp" .SourceTableName = strSourceTableName .Connect = "ODBC;" & strConnect End With CurrentDb.TableDefs.Append objTableDef
'If the new tabledef was successfully created, delete the old tabledef CurrentDb.TableDefs.Delete strTableName
'Change the name of the new tabledef to that of the old tabledef CurrentDb.TableDefs(strTableName & "Temp").Name = strTableName
End If Next Set objTableDef = Nothing Exit Function Trapper: MsgBox "Error setting connections to SQL Server Database" Exit Function End Function
<colin.anderson@justice.vic.gov.au> wrote in message news:1118113394.871278.122380@g47g2000cwa.googlegroups.com...> Hi>
I am trying to refresh table links at startup in an Access 2002> application. The following code is based on a number of articles> posted in this group but this does not seem to work:>
===CODE SNIPPET START===> For i = 0 To CurrentDb.TableDefs.Count - 1>
If Left(CurrentDb.TableDefs(i).NAME, 3) = "tbl" Then>
constODBC_ConnectString is a global string variable containing a valid> connect string.>
No errors are generated but the Connect property does not get updated> in either case. The original (manually linked) connect property is> maintained.>
Being a system administrator, I periodically use various data recovery services from other software developers. From my point of view, the ms sql database recovery utility: http://www.recoverytoolbox.com/microsoft_sql_server_database_recovery_download.html is very easy to use, it features intelligent data recovery algorithms that work under all supported software and hardware configurations.
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .