Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set keys for linked tables in access ?

Status
Not open for further replies.

pharcyder

Programmer
Mar 12, 2002
66
DE
Hello !

I have linked tables over an ODBC-Connection to an SQL-Server 2000.

The problem is, when I link the tables to Access 2000 it is NOT using the set keys (primary keys) in SQL Server 2000 but the ROWGUID-column (used for replication by SQL-Server).

If I remove the replication (and the ROWGUID-column), Access uses my set keys, but I am updating the linked tables regularly and I NEED the replication running.

By linking the tables MANUALLY, I can choose the key by hand, but HOW can I set the key via VBA ??? Here is the code I'm using to link the tables:

Dim dbs As DAO.Database
Dim tdfLinked As DAO.TableDef

Set dbs = CurrentDb

For Each tdfLinked In dbs.TableDefs
If (tdfLinked.Attributes And dbAttachedODBC) Then
tdfLinked.Connect="ODBC;DSN=MYDSN;DATABASE=MYDATABASE"
tdfLinked.RefreshLink
End If

Next tdfLinked

How can I tell Access the key it SHOULD use ?

Thanks in advance,
Jens K.
 
just altered the index on the SQL-Server, now it works...
doh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top