• Not Answered

Set Datalink Visibility DataSource from VBA

Hi All,

I have a DataLink that I am trying to set the Visibility from VBA when a timer is greater that 0. This particular case requires it to be set by VBA. I would normally I am trying to set the visibility condition to this DVSYS.MY_TIMER/TMR1/TM_PV.F_CV > 0.

I am having trouble finding this property of the object? (obj.Source.Visibility)?

2 Replies

  • The code changes the visibility condition for a rectangle (Rect32) that has been previously set up with a single visibility animation. The code is part of the project for the picture containing the rectangle. It may point you in the right direction.

    Dim objVisible As Object
    Set objVisible = FindLocalObject(Me, "Rect32")
    objVisible.ContainedObjects.Item(1).SetSource "DVSYS.TEST_MOD/TMR1/ELAPSED_TIMER.F_CV > 3"
  • In reply to Cedric Dawnhawk:

    In addition/alternative I would suggest adding If before setting the source:

    If Not objVisible Is Nothing Then

    End If

    If you don't have the If and it can't find an object, you will get a VB Error when trying to set the source.

    You can also name the visibility animation and search for this directly:

    Dim objVisible As Object
    Set objVisible = FindLocalObject(Me, "avRect32")
    If Not objVisible Is Nothing Then
        objVisible.Source "DVSYS.TEST_MOD/TMR1/ELAPSED_TIMER.F_CV > 3"
    End If

    Just be aware that if you copy the object and use it elsewhere that the name is auto generated and may affect the logic.

    If you have a lot of instances where you are setting sources of the object, you might want to search for the object name and set an object for that and then use that object to search for the local names.

    Set objDynamo = Nothing
    Set objDynamo= frsFindLocObj(Me, "Rect32")
    If (Not objDynamo Is Nothing) Then
        Set objVisible = FindLocalObject(objdynamo, "avRect32")
        If Not objVisible Is Nothing Then
            objVisible.Source "DVSYS.TEST_MOD/TMR1/ELAPSED_TIMER.F_CV > 3"
        End If

        'Do other source finding/setting using the objDynamo object
    End If