Author Topic: Dependson() Behaving Badly  (Read 4567 times)

0 Members and 1 Guest are viewing this topic.

pcarney

  • Newbie
  • *
  • Posts: 3
Dependson() Behaving Badly
« on: April 18, 2016, 09:45:24 AM »
I am trying to use DEPENDSON() to place TimeStamp info into Shape Data fields. The problem I am having is that it seems to trigger regardless of the dependency. My project is quite complex so to eliminate the possibility that I have something unintentionally triggering the events I decided to attempt the simplest implementation I can.

I am using MS Visio 2010.
1. create a new blank file.
2. create a square shape
3. open the shape sheet
4. add shape data section
5. add 3 shape data rows
6. in Prop.Row_2 insert formula DEPENDSON(PinX,PinY)+NOW()  ( this should trigger anytime the shape is moved)
7. in Prop.Row_3 insert formula DEPENDSON(Prop.Row_1)+NOW() (this should trigger when the value of Prop.Row_1 changes)

The problem that is that the date changes for both Prop.Row_2 and Prop.Row_3 whenever the shape is moved or I change the value of Prop_Row_1.

I also added a Prop.Row_4 and when I change it's value the Time in Prop.Row_2 and Prop.Row_3 also update.

What am I doing wrong? Is there a possible document or Visio setting that is interfering with the Function of Dependson? Do I have a syntax issue? I have reviewed a number of sites documenting the use of DEPENDSON and Timestamping and I thought this should work.

SubPlanner

  • Jr. Member
  • **
  • Posts: 62
Re: Dependson() Behaving Badly
« Reply #1 on: April 18, 2016, 01:13:55 PM »
Are you linked to external data in any way.
The reason I ask is that I had this problem also. I needed to timestamp my external data update (connected to Excel).
I ended up just creating a timenow() situation in Excel, so when I linked up to it, I had the date I needed.


SubPlanner.

vojo

  • Hero Member
  • *****
  • Posts: 1711
Re: Dependson() Behaving Badly
« Reply #2 on: April 19, 2016, 10:09:41 AM »
I believe NOW() will trigger the cell regardless of DEPENDSON.
So if you move it, edit it, etc....cells reevaluated - row_1 - and since NOW() is changed...triggers updates.

You may want to reevaluate the use of NOW()

Maybe something like (pseudo code)
User1 = if props.row_1 changes, then NOW(), else NOTHING

then use the user1 into your row_3 stuff

The correct implementation might more complex
(you might need user.prop1 and user.oldprop1....cells to update them as appropriate).

pcarney

  • Newbie
  • *
  • Posts: 3
Re: Dependson() Behaving Badly
« Reply #3 on: April 19, 2016, 10:11:39 AM »
No there is no external data linking.

Thanks for the confirmation that others have had similar issues.

To me it appears that using Now() ends up updating any shape where it is used in a formula when triggered.

I am also timestamping when the shape is added using the below formula in EventDrop cell. and it stays static. Where as when using dependson to trigger NOW() seems to tie all the Now() usage on the page together. Still trying to figure this part out.
SETF("Prop.Cable_DateAdded",NOW())

I am leaning towards a macro triggered by the Dependson and CALLTHIS to process the timestamps, hopefully similar to the way the formula in the EventDrop cell is working. Essentially separating the NOW() function from the Dependson unless I get a better suggestion out of the forum.


pcarney

  • Newbie
  • *
  • Posts: 3
Re: Dependson() Behaving Badly
« Reply #4 on: April 19, 2016, 11:29:28 AM »
So I have gone with the CALLTHIS option and I thought I would share the implementation.

I am using MS Visio 2010.
1. create a new blank file.
2. create a square shape
3. open the shape sheet
4. add shape data section
5. add 3 shape data rows
6. add user section
7. add 2 user rows
8. in User.Row_1 insert formula DEPENDSON(PinX,PinY)+CALLTHIS("ThisDocument.settime",,"Prop.Row_2") ( this should trigger anytime the shape is moved)
9. DEPENDSON(Prop.Row_1)+CALLTHIS("ThisDocument.settime",,"Prop.Row_3") (this should trigger when the value of Prop.Row_1 changes)
10. in ThisDocument object I placed the following Sub

Sub settime(shpObj As Visio.Shape, UpdateType As String)

    Dim Shp As Visio.Shape
    Set Sel = ActiveWindow.Selection

     Set Shp = Sel(1)
     If Shp.CellExists(UpdateType, 0) Then
            Shp.Cells(UpdateType).FormulaForceU = Chr(34) & Now() & Chr(34)
     End If
End Sub

This results in Prop.Row_2 getting updated with the time/date whenever the shape is moved and Prop.Row_3 being updated with the time/date whenever the Prop.Row_1 is updated. I would have preferred to keep this all self contained in the shapesheet but my project already has code in ThisDocument so it isn't that big of a deal.

I will probably add a For loop to process multiple shapes selected and moved at the same time but this proved the concept.