Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if relation exists

Status
Not open for further replies.

Kib

Programmer
May 17, 2001
58
US
What code would I use to check and make sure a relation by a certain name exists in the database? Thanks!
 
Hi,

This will tell you if a relationship exists between Table1 and Table2:

Dim dbs As Database, fld As DAO.Field, prp As DAO.Property, booExists As Boolean
On Error GoTo Err_Relation
booExists = False
Set dbs = CurrentDb
Set fld = dbs.Relations("Table1Table2").Fields(0)
For Each prp In fld.Properties
On Error Resume Next
If prp.Value <> &quot;&quot; Then
booExists = True
End If
On Error GoTo 0
Next prp
Err_Relation:
MsgBox booExists
dbs.Close

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top