AnsweredAssumed Answered

Avoid Processbook go to current time when context change programatically

Question asked by PedroCampos on Dec 10, 2018

Hello Everyone!

 

I have created an processbook display with Relative template, but I have one menu with buttons with all interest elements at the same page. I have created a macro to change the context of my processbook when I click over one of my elements.

 

The problem is when I am at a period on the past and click on the button to change the context. First of all the page go to current time and load al the values and trend to current time and then back to the period there I have chosen. I wold like to avoid this load to current time when I am in the past time.

 

Here is the code:

 

  1. Option Explicit 
  2. '- 
  3. '- Altera o contexto da tela de acordo com o elemento selecionado 
  4. '- 
  5. Sub changeContext() 
  6.  
  7.  
  8.     Dim pbButtons As Object 
  9.     Dim buttonName As String 
  10.     Set pbButtons = ThisDisplay.SelectedSymbols(1) 
  11.     Dim elementName As String 
  12.     Dim buttonNameArray() As String 
  13.     Dim path As String 
  14.      
  15.     buttonName = pbButtons.GetTagName(1) 
  16.      
  17.     buttonNameArray = Split(buttonName, "|") 
  18.      
  19.     path = Replace(buttonNameArray(0), "AF2.\\", "\\") 
  20.          
  21.     Dim sContext As String 
  22.     Dim mERDContext As ContextHandler 
  23.     Dim mDatabasePath As String 
  24.      
  25.     Set mERDContext = Application.ContextHandlers("E") 
  26.     sContext = path 
  27.     mERDContext.CurrentContext(ThisDisplay) = sContext 
  28.      
  29.     DoEvents 
  30.      
  31. End Sub 

 

 

 

Thanks.

Outcomes