Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

【Access函数】删除所有的关系

时 间:2012-08-09 08:16:26
作 者:Allen Browne   ID:6392  城市:昆山
摘 要:删除所有的关系
正 文:

警告:此代码是危险的!它会删除当前数据库中的所有关系。

Function DeleteAllRelationships() As String
 ' WARNING: Deletes all relationships in the current database.
     Dim db As Database      ' Current DB
     Dim rex As Relations    ' Relations of currentDB.
     Dim rel As Relation     ' Relationship being deleted.
     Dim iKt As Integer      ' Count of relations deleted.
     Dim sMsg As String      ' MsgBox string.
 
    sMsg = "About to delete ALL relationships between tables in the current database." & vbCrLf & "Continue?"
     If MsgBox(sMsg, vbQuestion + vbYesNo + vbDefaultButton2, "Are you sure?") = vbNo Then
         DeleteAllRelationships = "Operation cancelled"
         Exit Function
     End If
 
    Set db = CurrentDb()
     Set rex = db.Relations
     iKt = rex.Count
     Do While rex.Count > 0
         Debug.Print rex(0).Name
         rex.Delete rex(0).Name
     Loop
     DeleteAllRelationships = iKt & " relationship(s) deleted"
 End Function



Access软件网官方交流QQ群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助