Free for PREMIUM members
Open in new window
Dim db As DAO.Database
Dim rel As DAO.Relation
Dim fld As DAO.Field
Set db = CurrentDb()
'Create a new relation.
Set rel = db.CreateRelation("tblDaoContractortblDaoBooking")
'Define its properties.
'Specify the primary table.
.Table = "tblDaoContractor"
'Specify the related table.
.ForeignTable = "tblDaoBooking"
'Specify attributes for cascading updates and deletes.
.Attributes = dbRelationUpdateCascade + dbRelationDeleteCascade
'Add the fields to the relation.
'Field name in primary table.
Set fld = .CreateField("ContractorID")
'Field name in related table.
fld.ForeignName = "ContractorID"
'Append the field.
'Repeat for other fields if a multi-field relation.
'Save the newly defined relation to the Relations collection.
Set fld = Nothing
Set rel = Nothing
Set db = Nothing
Debug.Print "Relation created."
With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $151.20.
Premium members get this course for $37.50.
Premium members get this course for $389.00.
Premium members get this course for $31.25.
Premium members get this course for $62.50.
Premium members get this course for $159.20.
Premium members get this course for $167.20.