Create relationship between tables

knowledge76

Registered User.
Local time
Today, 20:00
Joined
Jan 20, 2005
Messages
165
Hi Friends,

I am trying to create and delete relationship between two tables and to enforce referential integrity between the two tables. The tables are in a 1 to many relationship. I am not able to create and delete the relationships. I would like to have suggestions from your side. Thanks

PHP:
Dim tbl1 As TableDef
Dim tbl2 As TableDef

Dim db As Database
Dim relnew As Relation


Set db = CurrentDb()

With db

Set tbl1 = db.TableDefs("CLAIMS")

'tbl 2 is a tabledef you just created
Set relnew = .CreateRelation(CLAIMS, PART)
relnew.Fields.Append relnew.CreateField("KEY") 
relnew.Fields!table1id.ForeignName = "KEY"

.TableDefs.Append PART


.Relations.Append relnew

.Close
End With

End Sub
 

Users who are viewing this thread

Back
Top Bottom