programmcatically create a relationship between tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to create a relaationship between tables in my vba code?
I want a relationship from Table1!Field1 to Table2!Field2
via VBA...
Maybe you can't work with relationships in VBA, because I find nothing in
the help file about it.
thanks
ck
 
Hi Charlie,

yes

look here:

Allen Browne's tips for Microsoft Access
http://allenbrowne.com/tips.html
Tips for Programmers
Examples by Library
DAO Code


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
I want a relationship from Table1!Field1 to Table2!Field2
via VBA...

ALTER TABLE table2
ADD CONSTRAINT mynewrel
FOREIGN KEY field2 REFERENCES table1(field1)

but be prepared for it to fail if you have any illegal values in
Table2.Field2
Maybe you can't work with relationships in VBA, because I find nothing
in the help file about it.

There is a much harder version mucking about with DAO but the good thing
about SQL is that it's quick, easy and portable.

Hope that helps

Tim F
 
Back
Top