开发者

Adding to MS Access relationship diagram programmatically

开发者 https://www.devze.com 2023-01-24 09:35 出处:网络
I have an application that ships to the customer with a JET database including a relationship diagram which more savvy users are invited to view to gain insight into the construction of the database.

I have an application that ships to the customer with a JET database including a relationship diagram which more savvy users are invited to view to gain insight into the construction of the database.

I also have code in my application to update the database structure when new versions r开发者_Go百科equire new tables, new columns, or modified queries. I do this by pushing SQL through the ADO connection it works fine.

The problem is that if I add a new table with a constraint that relates it to an existing table (for instance, I add EmployeeHobbies with an FK relationship to an existing PK in Employees), while the table is constructed correctly the new relationship does not appear in the relationship diagram. Over time the diagram becomes progressively less complete.

Is there a programmatic method to force Access to update its relationship diagram from constraint information in the database or, failing that, is the relationship diagram stored in some hidden system object that I can update directly to reflect my changes?

Edit: I failed to make clear that my application is written in Delphi, not MS Access. Users who have a copy of MS Access can see the relationship diagram, others cannot.


I do not know if RunCommand will suit, but for what it's worth:

DoCmd.RunCommand acCmdRelationships
DoCmd.RunCommand acCmdShowAllRelationships


You may be able to leverage Stephen Lebans' SaveRelationshipView for this. His code saves properties for each item from the Relationships view to a table. Later the same layout view can be recreated from the table.

You could adjust your copy of the Relationships view to determine the values to include for a new row in the tblRelationshipViews table. Then let the users recreate their Relationships view based on the updated table information. Perhaps you could even automate to do it for them automatically.

0

精彩评论

暂无评论...
验证码 换一张
取 消