Creating an UPDATABLE linked table

ZanyJanie

Registered User.
Local time
Today, 11:33
Joined
Mar 27, 2001
Messages
30
Within Access, I'm using the code shown below to create a link to a SQL Server table. My code works; but I need to make the linked table updatable.

If I create the link manually, Access prompts me to choose the "Unique Record Identifier" field(s); but I can't figure out how to provide this information from within my code.

Can anyone out there help me with this problem?


Thanks in Advance,
Jane

-----

strConnect = "ODBC;DRIVER={SQL Server}" _
& ";SERVER=" & strServer _
& ";DATABASE=" & strDB _
& ";UID=" & strUID _
& ";PWD=" & strPwd & ";"

Set strTblDef = db.CreateTableDef(strTblName)

strTblDef.SourceTableName = strTblName

strTblDef.Connect = strConnect

db.TableDefs.Append strTblDef
db.TableDefs.Refresh
 
I don't know the answer to your query but...

Access normally only prompts for this if the data source doesn't have a primary key defined. Is that the case here? If so, do you have any control over the way this table is set-up? Can you get a primary key index added to the table?

Simon
 
Thanks for your reply Simon. The SQL Server table has a primary key field; so that isn't the problem. My guess is that I need to pass a table definition or connection string parameter to tells Access which field(s) are the PK. I just don't know what that parameter is.

Still looking for the anwser!

Jane
 
Pat

Thanks for your help! You were right about my table not having a PK. It has an identity field that was originally defined as the PK. Recently, our DBA upgraded our SQL Server from version 7 to 2000. Somehow during the upgraed all of my database's PK's and indexes disappeared. After defining the PK again, my original code worked fine.

Thanks again!
Jane
 
Don'tcha love upgrades? They're so helpful.

David R
 

Users who are viewing this thread

Back
Top Bottom