Linking two shapes from different pages (parent-child)

Started by ofey, April 09, 2020, 07:54:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ofey

Hello Visio Guy community!

I am challenging one issue within the beginning phase of my Ph.D. and it has something to do with Visio Proffesional (-->crow's foot notation) :-) I am designing a database for one German public funded project and Visio helps me to create a picture with all of the project partners and their input/output data. Later on, my work will flow in MySQL.

Here is the question: I have two sheets (general_overview and material). The sheet material  has a shape material_parent with four attributes. There is a main sheet called general_overview with child shape material_child. My goal is that as soon as I add or delete name of an attribute inside material_parent the same happens in the shape material_child. The same with the shape name: every name change of the shape in the material_parent will be automatically done in the shape material_child.

I hope I have described the situation well enough. Please, give me some advises or ideas and do not hesitate to ask question.

Regards from Germany,
Nazar

vojo

add and delete name.....as in adding a new field or taking an old field away???
(this will be tough...need VBA since the data base of Visio elements changes)

or

add and delete name....as in changing the value of field  (from "ABC" to "XYZ")?
(this will be easy...user.parent1 = setf(getref(page.m!sheet.n!user.childvalue),user.parent1value)....got look at cell references to make sure syntax correct....the rub here is that will have set it up once manually...could be tedious)


ofey

Thanks vojo,

I meant the second option from your answer --> (add and delete name....as in changing the value of field  (from "ABC" to "XYZ")). I will try to set this code! Because of my not rich experince with Visio programming, I have no idea where to set the code you have written (--> user.parent1 = setf(getref(page.m!sheet.n!user.childvalue),user.parent1value)). This must be done in the sheet material within the shape material_parent? How do I write this code exactly? Maybe you can send my a screenshot of the relevant button (or field) in Visio from the file that I have attached in the very first post.



vojo

every shape has a shapesheet associated with it (right click).  In the shapesheet, there are cells that control the shape.
in cells, you can put simple values or complex formulas that can be comprised of functions.  One such function
is SETF.   Basically you can pick a cell (the getref(<cells in this shape or other shapes>)) and place a value in it (user.parent1value).   So this function pushes whatever value is in the user cell  (another type of cell in shapesheet)  user.parent1value into the user cell of a shape on a different page.
Any time the user.parent1value changes, this SETF is triggered to push to other cell  (you don't have to poll or anthing like that).

So to be more explicit
- a group shape with 1 child shape   (group is the parent that happened when you bundled the child shape up into group)
- group shape has 2 cells of interest (you created not default)...shape handle is 9999 (created by visio)
    -user.parent1
    -user.parent1value
-child shape has 1 cell of interest (you created not default)....shape handle is 3333  (created by visio)
    - user.childvalue
- in user.parent1value....you put the text "have a nice day" or the value 1234
- in user.parent1 ...you put SETF(getref(sheet.333!user.childvalue), user.parent1value)   
    -9999 only comes into play if its a 3rd or different shape   e.g.  Sheet.9999!user.parent1value
- ok so sometime later you change "have a nice day" to "have a rotten day"...change in parent1value will trigger parent1
  That will pus "have a rotten day" into childvalue cell.   Automatically

Lots of doc on the web about shapesheet, cells, functions.
Point is for just changing value, don't need VBA.   

If, however, you want to add another parent2...parent2value ... child2value "trifecta"
then need some VBA or have manual edit shapesheet to create it

wapperdude

#4
Here's example illustrating what Vojo has outlined.  The formulas are entered into the shape in question.  The example might represent your PK shape.

The attachment illustrates two methods.  First would be where the Child (yellow, page2) grabs from the Parent (orange, page1).  The 2nd would be where the parent shoves into the child (green, page2).  The methods break if text is entered directly into either child.  Either, don't allow that to happen, or more elaborate methods are required.


Visio 2019 Pro