ARRAY(0x5d8c618)
Connect property of linked ODBC table
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > MS Access database development > Connect property of linked ODBC table 8 February 2010 18:24:19

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

Connect property of linked ODBC table

Colin Anderson 7 June 2005 07:03:14
 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.Tabl­eDefs(i).NAME, 3) = "tbl" Then

CurrentDb.TableDefs­(i).Properties("Conn­ect") =
constODBC_ConnectSt­ring
CurrentDb.TableDefs­(i).Properties.Refre­sh
CurrentDb.TableDefs­(i).RefreshLink

MsgBox CurrentDb.TableDefs­(i).NAME & vbCrLf & vbCrLf &
CurrentDb.TableDefs­(i).Connect

End If

Next i
===CODE SNIPPET END===

I also tried:

===CODE SNIPPET START===
For i = 0 To CurrentDb.TableDefs­.Count - 1

If Left(CurrentDb.Tabl­eDefs(i).NAME, 3) = "tbl" Then

CurrentDb.TableDefs­(i).Connect = constODBC_ConnectSt­ring
CurrentDb.TableDefs­(i).RefreshLink

MsgBox CurrentDb.TableDefs­(i).NAME & vbCrLf & vbCrLf &
CurrentDb.TableDefs­(i).Connect

End If

Next i
===CODE SNIPPET END===


constODBC_ConnectSt­ring 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.

Please help.

Add comment
Indrid Colt 7 June 2005 07:53:24 permanent link ]
 Hi, try my tool : http://www.logiciel­appui.com/tips/AccXP­_LoginMDB_SQL.zip

Robert Simard
Logipro
http://www.logiciel­appui.com/tips (French Only)


<colin.anderson@jus­tice.vic.gov.au> a йcrit dans le message de news:
1118113394.871278.1­22380@g47g2000cwa.go­oglegroups.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.Tabl­eDefs(i).NAME, 3) = "tbl" Then>
CurrentDb.TableDefs­(i).Properties("Conn­ect") => constODBC_ConnectSt­ring> CurrentDb.TableDefs­(i).Properties.Refre­sh> CurrentDb.TableDefs­(i).RefreshLink>
MsgBox CurrentDb.TableDefs­(i).NAME & vbCrLf & vbCrLf &> CurrentDb.TableDefs­(i).Connect>
End If>
Next i> ===CODE SNIPPET END===>
I also tried:>
===CODE SNIPPET START===> For i = 0 To CurrentDb.TableDefs­.Count - 1>
If Left(CurrentDb.Tabl­eDefs(i).NAME, 3) = "tbl" Then>
CurrentDb.TableDefs­(i).Connect = constODBC_ConnectSt­ring> CurrentDb.TableDefs­(i).RefreshLink>
MsgBox CurrentDb.TableDefs­(i).NAME & vbCrLf & vbCrLf &> CurrentDb.TableDefs­(i).Connect>
End If>
Next i> ===CODE SNIPPET END===>
constODBC_ConnectSt­ring 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.>
Please help.>


Add comment
Guest 7 June 2005 12:27:41 permanent link ]
 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.SourceTabl­eName

'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

Add comment
Terry Kreft 7 June 2005 16:09:25 permanent link ]
 It won't work because of your use of Currentdb.


===CODE SNIPPET START===
Dim loDb as DAO.Database

Set lodb = Currentdb

For i = 0 To lodb.TableDefs.Coun­t - 1

If Left(lodb.TableDefs­(i).NAME, 3) = "tbl" Then

lodb.TableDefs(i).P­roperties("Connect")­ = constODBC_ConnectSt­ring
lodb.TableDefs(i).P­roperties.Refresh
lodb.TableDefs(i).R­efreshLink

MsgBox lodb.TableDefs(i).N­AME & vbCrLf & vbCrLf &
lodb.TableDefs(i).C­onnect

End If

Next i
===CODE SNIPPET END===

Terry Kreft

<colin.anderson@jus­tice.vic.gov.au> wrote in message
news:1118113394.871­278.122380@g47g2000c­wa.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.Tabl­eDefs(i).NAME, 3) = "tbl" Then>
CurrentDb.TableDefs­(i).Properties("Conn­ect") => constODBC_ConnectSt­ring> CurrentDb.TableDefs­(i).Properties.Refre­sh> CurrentDb.TableDefs­(i).RefreshLink>
MsgBox CurrentDb.TableDefs­(i).NAME & vbCrLf & vbCrLf &> CurrentDb.TableDefs­(i).Connect>
End If>
Next i> ===CODE SNIPPET END===>
I also tried:>
===CODE SNIPPET START===> For i = 0 To CurrentDb.TableDefs­.Count - 1>
If Left(CurrentDb.Tabl­eDefs(i).NAME, 3) = "tbl" Then>
CurrentDb.TableDefs­(i).Connect = constODBC_ConnectSt­ring> CurrentDb.TableDefs­(i).RefreshLink>
MsgBox CurrentDb.TableDefs­(i).NAME & vbCrLf & vbCrLf &> CurrentDb.TableDefs­(i).Connect>
End If>
Next i> ===CODE SNIPPET END===>
constODBC_ConnectSt­ring 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.>
Please help.>


Add comment
Guest 21 August 2007 23:31:05 permanent link ]
 Why does the code work with a reference of CurrentDb, but not CurrentDb directly?
Add comment
Guest 8 February 2010 18:24:19 permanent link ]
 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.recovery­toolbox.com/microsof­t_sql_server_databas­e_recovery_download.­html is very easy to use, it features intelligent data recovery algorithms that work under all supported software and hardware configurations.
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > MS Access database development > Connect property of linked ODBC table 8 February 2010 18:24:19

see also:
"Learning Perl" Question
Re:pl2bat issue
Caching Large Data Structures To Disk
pass tests:
see also:
My heart.....
Memories......

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .