VBA: linking a table from a secured access-db 
Author Message
 VBA: linking a table from a secured access-db

Hi Super-Users!

I'm trying to set (via VBA) a linked table in an Access97-Database, which
should refer to a table within another passwort-secured(!!)
Access97-Database.

My (attached) procedure works fine, BUT it always prompts for the password
at "TransferDatabase" although it has opened the database in question
before.

I'm looking forward to any late Christmas presents (i.e. a solution or
workaround) for me.
Thank You very much in advance and a Happy New Year.

Answers please to my E-Mail-address, too.
-robert g.-

---

--- My procedure is following:

Private Sub LinkAccessTable()
  Dim db As Database
  Dim TableNameOriginal As String
  Dim TableNameCopy As String
  Dim MyFileName As String
  Dim MyPassword As String

  TableNameOriginal = "HugoTest"
  TableNameCopy = "TestTabelle"
  MyFileName = "C:\DB1.MDB"
  MyPassword = "hugo"

  Set db = OpenDatabase(MyFileName, False, True, ";pwd=" & MyPassword)

  DoCmd.TransferDatabase acLink, "Microsoft Access", MyFileName, acTable, _
      TableNameOriginal, TableNameCopy, False
End Sub



Sat, 16 Jun 2001 03:00:00 GMT  
 VBA: linking a table from a secured access-db
Hi Robert

TransferDatabase does not handle connection strings well - try using
CreateTableDef instead:

    Dim tdf as TableDef
    Set db = CurrentDB
    Set tbl = db.CreateTableDef(TableNameCopy)
    tdf.SourceTableName = TableNameOriginal
    tdf.Connect = ";DATABASE=" & MyFileName & ";pwd=" & MyPassword
    db.TableDefs.Append tdf

You also don't need the OpenDatabase line.

Good Luck!
Graham Mandeno [Access MVP]
Alpha Solutions Limited
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.

Please post new questions to newsgroups.

Quote:

>Hi Super-Users!

>I'm trying to set (via VBA) a linked table in an Access97-Database, which
>should refer to a table within another passwort-secured(!!)
>Access97-Database.

>My (attached) procedure works fine, BUT it always prompts for the password
>at "TransferDatabase" although it has opened the database in question
>before.

>I'm looking forward to any late Christmas presents (i.e. a solution or
>workaround) for me.
>Thank You very much in advance and a Happy New Year.

>Answers please to my E-Mail-address, too.
>-robert g.-

>---

>--- My procedure is following:

>Private Sub LinkAccessTable()
>  Dim db As Database
>  Dim TableNameOriginal As String
>  Dim TableNameCopy As String
>  Dim MyFileName As String
>  Dim MyPassword As String

>  TableNameOriginal = "HugoTest"
>  TableNameCopy = "TestTabelle"
>  MyFileName = "C:\DB1.MDB"
>  MyPassword = "hugo"

>  Set db = OpenDatabase(MyFileName, False, True, ";pwd=" & MyPassword)

>  DoCmd.TransferDatabase acLink, "Microsoft Access", MyFileName, acTable, _
>      TableNameOriginal, TableNameCopy, False
>End Sub



Sun, 17 Jun 2001 03:00:00 GMT  
 VBA: linking a table from a secured access-db
On Tue, 29 Dec 1998 21:59:38 +0100, "Robert Gelbmann"

Quote:

>I'm trying to set (via VBA) a linked table in an Access97-Database, which
>should refer to a table within another passwort-secured(!!)
>Access97-Database.

>My (attached) procedure works fine, BUT it always prompts for the password
>at "TransferDatabase" although it has opened the database in question
>before.

>  Set db = OpenDatabase(MyFileName, False, True, ";pwd=" & MyPassword)

>  DoCmd.TransferDatabase acLink, "Microsoft Access", MyFileName, acTable, _
>      TableNameOriginal, TableNameCopy, False

The db object has no relevance to the following line: TransferDatabase
will create a brand new connection to the database, perhaps even using
a new workspace.

In any case,

From MS Access 97 Help:
-----------------------------------------------------------------------
Note   Although you can use the TransferDatabase method in Visual
Basic to link tables, it's recommended that you use Data Access
Objects (DAO) instead. To create a link by using DAO, use the Connect
property for the TableDef object.
-----------------------------------------------------------------------

HTH

Tim F

--



Sun, 17 Jun 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. accessing records in one secure DB from another secure DB - programatically

2. Linking to a secure Access DB from VB5.0

3. Accessing Linked Table in a Secure Workgoup

4. Accessing a secured db via VBA?

5. Saving embedded word 97 docs in Access db with linked SQL Server tables

6. Help w/VB4 & Linked Access DB Tables

7. ASP reading Access DB with linked Foxpro tables, not working

8. SQL Tables Linked to Access DB

9. linking multiple tables from VB app from Access DB

10. linking multiple tables from VB app from Access DB

11. SQL Tables Linked to Access DB

12. Linked table in Access 97 using VBA code ????

 

 
Powered by phpBB® Forum Software