Liniking to Pervasive table (1 Viewer)

Freshman

Registered User.
Local time
Today, 19:55
Joined
May 21, 2010
Messages
437
Hi all,

I'm using this code to link to a ODBC Pervasive db table:

Public Function RelinkODBC()
PastelServer = "PasServer"

On Error Resume Next
CurrentDb.TableDefs.DELETE "TranLeave"
Set tdfLinked = CurrentDb.CreateTableDef("TranLeave")
tdfLinked.Connect = "ODBC;DSN=" & PastelServer & ";DBQ=" & PastelServer
tdfLinked.SourceTableName = "TranLeave"
CurrentDb.TableDefs.Append tdfLinked
CurrentDb.TableDefs.Refresh
End Function

The resulting table is however read-only.
However if I link to the table "manually" myself it results in a read/write table.
Am I missing something in the above procedure?

Thanks
Pierre
 

spikepl

Eledittingent Beliped
Local time
Today, 18:55
Joined
Nov 3, 2010
Messages
6,142
You could check/cheat by connecting manually, and then reading the value of .Connect for the working table.
 

Freshman

Registered User.
Local time
Today, 19:55
Joined
May 21, 2010
Messages
437
Thanks I did try that but both lines look identical.
The only diffrence I can pick up while doing the link manually is that it asks me for the "Select Unique Record Identifier" which is not spesified anywhere in the VBA code method.
That made me look at the design view of the 2 tables and I noticed that the one created manually has a primary key and the other not.
So somewhere in the code I have to be able to set the p/key. Just not sure where in the script I can do that as trying to do it afterward is not possible due it being a linked table.
 

Freshman

Registered User.
Local time
Today, 19:55
Joined
May 21, 2010
Messages
437
Ahh - Google is my friend.
I had to end of the script with the following line:

CurrentDb.Execute "CREATE UNIQUE INDEX MyField ON MyTable (MyField) WITH PRIMARY"
 

Users who are viewing this thread

Top Bottom