اذهب الي المحتوي
أوفيسنا

كود عمل علاقة بين جدولين وايضاً طباعة العلاقات


alswedi

الردود الموصى بها

هذا هو الكود للربط

و أيضا كود لطباعة العلاقات الي نافذة ال debug

 

'create a relation 
'================= 
Sub CreateRelationDAO() 
Dim dbsLocal As Database 
Dim relLocal As Relation 
Dim fldLocal As Field 

Set dbsLocal = CurrentDb 
Set relLocal = dbsLocal.CreateRelation() 
With relLocal 
.Name = "PeopleFood" 
.Table = "tblFoods" 
.ForeignTable = "tblPeople" 
.Attributes = dbRelationDeleteCascade 
End With 
Set fldLocal = relLocal.CreateField("FoodID") 
fldLocal.ForeignName = "FoodID" 
relLocal.Fields.Append fldLocal 
dbsLocal.Relations.Append relLocal 
End Sub 

'print relation 
'================ 
Sub EnumRelations() 
Dim dbsLocal As Database 
Dim relLocal As Relation 

Set dbsLocal = CurrentDb 
For Each relLocal In dbsLocal.Relations 
Debug.Print relLocal.Table & " Related To: " & relLocal.ForeignTable 
Next relLocal 
End Sub

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information