The code would be something like this:
Dim db As DAO.Database
Dim rel As DAO.Relation
Dim fld As DAO.Field
'Initialize
Set db = CurrentDb()
'Create a new relation.
Set rel = db.CreateRelation("StatusCN43")
'Define its properties.
With rel
'Specify the primary table.
.Table = "tbl Status"
'Specify the related table.
.ForeignTable = "tbl CN43"
'Specify attributes for cascading updates and deletes.
.Attributes = dbRelationUpdateCascade + dbRelationDeleteCascade
'Add the fields to the relation.
'Field name in primary table.
Set fld = .CreateField("Status")
'Field name in related table.
fld.ForeignName = "Status"
'Append the field.
.Fields.Append fld
End With
'Save the newly defined relation to the Relations collection.
db.Relations.Append rel
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"mohd21uk via AccessMonster.com" <u20517@uwe> wrote in message
news:621b308278ce2@uwe...
>I have a table called tbl Status which has a field called Status and a
>table
> called tbl CN43 with a field called Status. I would like to link both the
> fields together using VBA code. I would be grateful if you could provide
> me
> the code to do this.