Can someone tell me if it is possible or not to have a public variable declared in exemple in Project_DefaultRes?
<font class="small">Code:</font><hr /><pre>
Sub TestLab_TestSetTests_FieldCanChange(FieldName, NewValue)
select case FieldName
if CInt(NewValue) = CInt(TestSetTest_Fields("TC_USER_20").Value) then
In TestLab_TestSetTests_FieldCanChange, the case 'else' works at first enty in sub. But when the event appears the second time (newvalue has replace old value in field), the variable oldvalue is ="".
So, In conclusion, oldvalue is not a global (public) variable.
What is the workaround ?
Variable scope problem : if you "declare" oldvalue in the Project_DefaultRes function, it's not visible outside of that function.
As you did not use the "Option Explicit" statement in the workflow module for the TestLab, there is no error on the statement "oldvalue = NewValue" : that "oldvalue" is automatically declared as local to the TestLab_TestSetTests_Field sub.
Move the Dim oldValue statement outside of the Project_DefaultRes function (outside of all functions / subs by the way) : this will make it a "global" variable that you can access from all functions/subs of the workflow, unless you Dim the same variable inside a function/sub.
Also, use Option Explicit at the beginning of each workflow module, use On Error Resume Next at the beginning of each function/sub and "If Err <> 0 Then MsgBox Err.Description" and "On Error GoTo 0" at the end of each function/sub.