programmcatically create a relationship between tables

C

Charlie

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
 
S

strive4peace

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
*
 
T

Tim Ferguson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top