473,762 Members | 8,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating ODBC table links

Hi all,
I'm having quite a bit of trouble with code to create linked tables in
Access 2K. I create a DAO tabledef using CreateTableDef against a DAO
database object, then set its connection string appropriately. The
trouble is when I go to append the tableDef to the collection I get
error 3264:
No field defined --cannot append TableDef or Index

Any suggestions?

Many thanks,

Eric

Code follows:
Public Function LinkAllTables()
' Link all tables

Dim rstTableNames As New ADODB.Recordset
Dim sGetTableNamesS QL As String, sConnStr As String

' SQL to read the list of tablenames
sGetTableNamesS QL = "SELECT DISTINCT table_name, table_schema FROM
information_sch ema.table_privi leges " _
& " WHERE table_schema <> 'information_sc hema' and table_schema
<>'pg_catalog ' " _
& " ORDER BY table_name; "
Dim tdf As DAO.TableDef
Dim db As DAO.Database
Set db = DBEngine.Worksp aces(0).Databas es(0)
With rstTableNames
Set .ActiveConnecti on = GetPGConnStr
.LockType = adLockReadOnly
.CursorLocation = adUseServer
.Source = sGetTableNamesS QL
.Open
While Not .EOF
Set tdf = db.CreateTableD ef(.Fields("tab le_name"), , _
.Fields("table_ schema") & "." & .Fields("table_ name"))

tdf.Connect = GetPGConnStr
'tdf.Attributes = dbAttachedODBC
db.TableDefs.Ap pend tdf
.MoveNext
Wend
End With
End Function

Public Function GetPGConnStr() As String
GetPGConnStr =
"ODBC;DSN=lims; DRIVER=PostgreS QL;SERVER=local host;PORT=5432; "
End Function
Nov 13 '05 #1
4 13498
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The error you are getting is saying that the defined table needs the
columns (aka Fields ) defined that go w/ that table. IOW, you need the
full meta-definition of that table (columns, unique indexes, primary
keys) to "re-construct" it as an Access linked table.

To link ODBC tables it is easier to run the TransferDatabas e method of
the DoCmd object. Unfortunately, if the tables don't have unique
indexes/primary keys defined you will be prompted for those fields when
you run the TransferDatabas e method.

When that happens - what I've done is just Escape thru the pop-up prompt
& run a DDL statement (in an Access query) that adds the index/PK
constraints.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQaFTfoechKq OuFEgEQKubwCfZg MiBhgSzCwqZ86pl PS5gwaewAoAn3yu
uxwo3tBk2d1gVQa RjXRhAdHv
=hRBs
-----END PGP SIGNATURE-----
Eric E wrote:
Hi all,
I'm having quite a bit of trouble with code to create linked tables
in Access 2K. I create a DAO tabledef using CreateTableDef against a
DAO database object, then set its connection string appropriately. The
trouble is when I go to append the tableDef to the collection I get
error 3264:
No field defined --cannot append TableDef or Index

Any suggestions?

Code follows:
Public Function LinkAllTables()
' Link all tables

Dim rstTableNames As New ADODB.Recordset
Dim sGetTableNamesS QL As String, sConnStr As String

' SQL to read the list of tablenames
sGetTableNamesS QL = "SELECT DISTINCT table_name, table_schema FROM
information_sch ema.table_privi leges " _
& " WHERE table_schema <> 'information_sc hema' and table_schema
<>'pg_catalog ' " _
& " ORDER BY table_name; "
Dim tdf As DAO.TableDef
Dim db As DAO.Database
Set db = DBEngine.Worksp aces(0).Databas es(0)
With rstTableNames
Set .ActiveConnecti on = GetPGConnStr
.LockType = adLockReadOnly
.CursorLocation = adUseServer
.Source = sGetTableNamesS QL
.Open
While Not .EOF
Set tdf = db.CreateTableD ef(.Fields("tab le_name"), , _
.Fields("table_ schema") & "." & .Fields("table_ name"))

tdf.Connect = GetPGConnStr
'tdf.Attributes = dbAttachedODBC
db.TableDefs.Ap pend tdf
.MoveNext
Wend
End With
End Function

Public Function GetPGConnStr() As String
GetPGConnStr =
"ODBC;DSN=lims; DRIVER=PostgreS QL;SERVER=local host;PORT=5432; "
End Function

Nov 13 '05 #2
Hi,
Many, many thanks for the tip. The TransferDatabas e method works well,
and, as you predicted, linking to tables/view that don't expose a
primary key produces the same popup that occurs when using the table
linking wizard. Is there any way I can pass a SendKeys argument to
automatically hit ESC in these cases?

Thanks,

EE
MGFoster wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The error you are getting is saying that the defined table needs the
columns (aka Fields ) defined that go w/ that table. IOW, you need the
full meta-definition of that table (columns, unique indexes, primary
keys) to "re-construct" it as an Access linked table.

To link ODBC tables it is easier to run the TransferDatabas e method of
the DoCmd object. Unfortunately, if the tables don't have unique
indexes/primary keys defined you will be prompted for those fields when
you run the TransferDatabas e method.

When that happens - what I've done is just Escape thru the pop-up prompt
& run a DDL statement (in an Access query) that adds the index/PK
constraints.

Nov 13 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

SendKyes -> Esc? Not that I know of. Since I consider linking ODBC
tables & views a developing/Administrator event I don't make it user
friendly. It's just a subroutine I run thru the debug window.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQaKg7oechKq OuFEgEQJTAgCeMc b8oXQQPv109aoxY 9GrSnWjSoIAoOvF
NuqNNjTKfTTfRyV uLMdUNy+9
=nz3F
-----END PGP SIGNATURE-----

Eric E wrote:
Hi,
Many, many thanks for the tip. The TransferDatabas e method works
well, and, as you predicted, linking to tables/view that don't expose a
primary key produces the same popup that occurs when using the table
linking wizard. Is there any way I can pass a SendKeys argument to
automatically hit ESC in these cases?

Thanks,

EE
MGFoster wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The error you are getting is saying that the defined table needs the
columns (aka Fields ) defined that go w/ that table. IOW, you need the
full meta-definition of that table (columns, unique indexes, primary
keys) to "re-construct" it as an Access linked table.

To link ODBC tables it is easier to run the TransferDatabas e method of
the DoCmd object. Unfortunately, if the tables don't have unique
indexes/primary keys defined you will be prompted for those fields when
you run the TransferDatabas e method.

When that happens - what I've done is just Escape thru the pop-up prompt
& run a DDL statement (in an Access query) that adds the index/PK
constraints.

Nov 13 '05 #4
Yeah, that's what I'm doing now. I was hoping to run a relink the first
time each user logged in, so that only the tables s/he has at least
SELECT access to would show up. I'll just have to work around it, I
guess. Anyway, thanks again for the helpful advice.

Cheers,

Eric

MGFoster wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

SendKyes -> Esc? Not that I know of. Since I consider linking ODBC
tables & views a developing/Administrator event I don't make it user
friendly. It's just a subroutine I run thru the debug window.

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5679
by: Galina | last post by:
Hello I am trying to create a table, which includes a field type LONG. The wizard hasn't allowed me to enter storage settings for this table. It set the initial size is 64K and not available to change, next size 0K, increase size by 0%. Since I am going to copy data from an existing MS Access table into this one, I know that the initial amount of records will be about 70000 and it will take about 7 Mb of disk space. I know it, because I...
0
1825
by: LesM | last post by:
This is a change of behaviour between Access 2000 SP3 and Access 2002 SP3. I have Progress table that is linked via ODBC into Access using OpenLink Lite for Progress 9.0b. For over a year, using Access 2000 under Win98, I have been running a Make Table or Append query against this ODBC table and producing an extracted Access table. Any fields that are NULL on the source ODBC table show as NULL on the output table. The query also has an...
3
11768
by: colin.anderson | last post by:
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.TableDefs(i).NAME, 3) = "tbl" Then
7
1700
by: Patrick Olurotimi Ige | last post by:
I have a simple Stored Procedure with multiple select statements..doing select * from links for example. I created a DataTable and then fill the tables But the first dtTemplate DataTable doesn't give the error but the links does! I get the error on this LINE(when looping):- PageLinks.Text = PageLinks.Text & dtLinks.Rows(iLoop)("link_url")
2
1870
by: mvl_groups_user | last post by:
I am trying to look up data on about 1000 records from a 6 million record view on a DB2 database using msaccess. The 6 million record DB2 view is connected through a linked ODBC table (table A), and the 1000 primary key numbers I want are in a local msaccess table (table B). The most obvious solution is to join table A and B, but this is excruciatingly slow performance-wise.
5
1296
by: Randy Harris | last post by:
I've seen several very nice routines on various web sites to fix table links when a file is moved. So far all the ones I've found have used DAO. Anyone know of a sample of such a routine that uses ADO? Thanks, Randy
5
2100
by: aaron.m.johnson | last post by:
I have an application which contains an Access database with linked tables that point to another database within the application. The problem I have is that when the user installs the application, I need to update the table links so that the paths are correct for the install directory. Is there an easy way to accomplish this? I'd really like to avoid duplicating the data in the linked tables, but if updating the links is too much work,...
0
1198
by: rdemyan | last post by:
Is there a way to check the validity of front-end table links on a backend file where all permissions to data have been revoked. To get at the data, the front end uses RWOP queries. What I'm trying to do is to avoid having to always delete table links and recreate them at startup since this takes quite awhile. I know you can try to open a recordset, but this fails because unless the user is the owner, they have no permissions on the...
1
1750
by: Scott | last post by:
Is it possible to edit/input a ODBC table in MS Access?
0
9378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3914
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.