[AccessD] Programmatically creating relationships

Steve Conklin developer at ultradnt.com
Tue Mar 27 20:33:45 CDT 2007


Try something like this (DAO): 
    db.Execute "ALTER TABLE M_Employees ADD CONSTRAINT fk_Employee_Dept
FOREIGN KEY (Dept_ID) REFERENCES L_Departments (Dept_ID);" 

Steve





-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Tuesday, March 27, 2007 1:39 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Programmatically creating relationships

I am starting the process of migrating a large database from Access to SQL
Server.  One of the things I have to do is go find all the places where
relationships were missed / couldn't be established for some reason and get
them in there.  I am doing this offline first and being the meticulous guy I
am, I want to be able to build up a program that does much of this stuff so
that as I document what has to be done, I also have code that will do it the
next time.
 
For example, I have written a function that finds orphaned records in a
child table and deletes them out.  What I need to do next is establish a
relationship between the parent / child.  I can write that code but have
never done so and would use borrowed code if anyone out there has a lib of
such relationship oriented functions.  Given a parent table / PK and a child
table / FK, establish a relationship.
 
Does anyone have that?
 
John W. Colby
Colby Consulting
www.ColbyConsulting.com


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list