473,765 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 2007: Creating a local relationship between two remote ODBCtables

Hi folks, thanks for taking the time to read this (and hopefully point
our where I'm going wrong).

The scenario:

I have a local Access2007 database which links in several read only
mySql tables via ODBC.

The problem:

I need to programmaticall y (in a VBA module) create the relationship
diagram in the access database between the linked tables, just like
you can do in the Relationship editor. (Drag the foreign key of the
child to the primary key in the parent).

For example, say I have two tables: Parents hasMany Children

Parents
id (PK)
Children
id (PK)
parent_id (FK to Parents.id)

So far, I have the following:

Dim r As Relation
Dim ff As Field

Set r = New Relation

With r
.Name = "Parent_Childre n"
.Table = "Children"
.ForeignTable = "Parent"

Set ff = New Field
ff.Name = "parent_id"
ff.ForeignName = "id"

r.Fields.Append ff

CurrentDb.Relat ions.Append r ' *** fails on this line

End With

The error I'm getting is:

Run-time error '3613':

Cannot create a relationship on linked ODBC tables.

Which makes me think access is trying to pass the relationship off to
the (read only) ODBC datasource and not adding it to the local
relations collection.

How do I add it to the local collection (ie, the one used by the
Relationship diagram)?

Thanks in advance
Richard.
Jan 11 '08
10 4455
"Richard@Ho me" <ri***********@ gmail.comwrote in
news:96******** *************** ***********@x69 g2000hsx.google groups.co
m:
David Wrote:
>Why are you using a generic library to create a structure that is
proprietary to Access?

Because it was the first example of code that creates relations
that I found, most of the other example I found used the same
libraries (or referred to the original code I found). I'm a PHP
coder by profession and only use odd bits of Microsoft
technologies thrown in when requested by the client.
Ah. Then you're a victim of Microsoft's ill-fated promotion of ADO
over native methods for working with Jet data. MS has changed their
mind, but way too many people never got the memo.

[Well, some of us didn't need a memo from MS, since we knew ADO
never made sense for Jet data]
>I don't know for a fact that DAO can create
the non-enforced relationship, but it would be the first choice,
since you're altering something in a Jet MDB (i.e., the front
end).

Ok, no problem. I'm always happy to learn. What technology would
you use in this case? A small snippet of example code would be
very useful too :-)
I'd use DAO. I don't do this kind of thing in code, so wouldn't know
how to do it, but the code Lyle gave you looks about right.
Lyle wrote:
>Set r = DbEngine(0)(0). CreateRelation( "NameofRelation ")
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jan 25 '08 #11

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

Similar topics

5
2903
by: steve | last post by:
Hi, I finally figured out the best way to synch local and remote script folders, containing many php script files. What I used to do before was try to ftp all the changed files, etc. which was tedious and often broke. It was also very slow. What I do now is to pkzip the folder up, ftp the pkzip’ed data to remote, and then unzip it there, which recreates the directories and files.
49
4359
by: Allen Browne | last post by:
If you are looking for opinon on what's useful in Access 2007, there's a new article at: http://allenbrowne.com/Access2007.html Covers what's good (useful features), what's mixed (good and bad), what's gone (features removed), what's fixed (old issues solved), what's broken (new bugs), configuration, compatibility, should you buy, and links. It is opinion, so you may disagree, but hopefully it's an informative summary.
4
5483
by: Neil | last post by:
Just found out that the Microsoft Rich Textbox does not support full text justification, since it's based on Version 1.0 of the RichEdit Window Class, and full text justification is only available in versions 3.0 or later of the class. However, also just found out that the new Rich Text property in Access 2007 ALSO does not support full text justification! This seems incredible, that MS would create a brand new application, and not...
1
5086
by: Ted Kennedy | last post by:
I have an Access Data Project (.adp) connecting to a SQL Server 2005 DB over the internet. The project has been running in Access 2003 for a couple of years, and performance has been very good. When I convert it to Access 2007 (maintaining the 2002-2003 file format) it gets a LOT slower. It takes about 3-5 seconds just to tab to a new field. Everything seems to work, it's just as if it is moving in molasses. Any ideas on what could be...
0
2699
by: raylopez99 | last post by:
10 years ago, the below was written (see very end, after my signature RL). What, if anything, has changed? I have Access 2003 and soon Access 2007 on a Windows XP Professional or Windows Vista Ultimate machine, with SQL Server Express running on it, and I want somebody, with a password (which I will provide) to be able to log onto a A03 or A07 dB from the internet. Now that I type this I realize that unless I put the database onto a...
3
7752
by: Brett Barry: Go Get Geek! | last post by:
Hello, I just started using Access 2007 after using Access 2003 for a long time. I've created all my queries and they work fine. However, either I forgot or it has changed but, how do I create a report based off of multiple queries? I tried using the report wizard using one query. In the Properties sheet of the report, the record source for the report only shows one query. But if I try and add another text box and add the control
1
3328
by: Jeff | last post by:
I've built a moderately complex table relationship using Access 2007 and back-saving to 2003; my partner on the project has made edits in Access 2003. Today I was unable to open Relationship view using 2007 - crashed the database, prompting to "restart and rebuild" after the crash. Tried: - saving as 2007 (*.accdb) - compact and repair (using both 2003 and 2007) - removing all "subdatasheet" relationships
0
1284
by: musicloverlch | last post by:
I have a database called RADB.mdb. I am working in Access 2007, but have to create a db in Access 2000 as some users don't have Access 2007. Everytime I setup an ODBC link in my database, Access creates a new database in Access 97 version and puts the link there. If I open up one of these databases and try to add another link, it still won't create it in that database! I am getting frustrated. Thanks, Laura
3
1513
by: Edward Gorman | last post by:
Hello Everyone, I'm having abit of difficulty with an aspect of Access. I wish to create a query which changes a persons wage depending upon their age. This is what I have done so far: SELECT Tble_Staff., Tble_Staff., Tble_Staff. AS Normal_Wage FROM Tble_Staff WHERE IIF(=12,13,IIF(=13,13.34,IIF(=14,13.78,IIF(=15,14,IIF(=16,14.50,IIF(=17,14.70,IIF(>=18,15.60,"Invalid Number"))))))); Now, I have the feeling that this doesn't work...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
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
10164
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...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
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...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
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
5277
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...
2
3532
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.