Hi Dmitry,
if lc is set to thecontrol.controlsource:
lc = thecontrol.constrolsource
then:
lcAlias = getwordnum(lc,1,".")
and:
lcField = getwordnum(lc,2,".")
thus:
luOldVal = oldval(lcField, lcAlias)
If you only use the field, you would also have to be on the alias.
If your code is already taking this into account -- well, never mind. :)
Hank
>>>>>>Hi,
>>>>>>
>>>>>>Could someone suggest why I am having a problem (actually not me but the customer) in the following segment of code:
>>>>>>
>>>>>>The container with the text box has a property control_source. This property has a value V_WORK.EMPLOYEE
>>>>>>
>>>>>>The code then checks is the value of the field EMPLOYEE in the cursor V_WORK has been change. Here is the code:
>>>>>>
>>>>>>
>>>>>> cControlSource = ALLTRIM( this.control_source )
>>>>>> IF EVALUATE( cControlSource ) == OLDVAL( cControlSource )
>>>>>> RETURN .T.
>>>>>> ENDIF
>>>>>>
>>>>>>
>>>>>>The problem occurs on the line above, EVALUATE( cControlSource ) == OLDVAL( cControlSource ), and it does
>>>>>>ALIAS IS NOT FOUND. I verified that the entry in .control_source exists as described above.
>>>>>>
>>>>>>TIA.
>>>>>>
>>>>>>UPDATE. the following code checks that the alias V_WORK exist and is open. This code, below, is before the code above (just in case someone wonders if the alias is indeed exists and open
>>>>>>
>>>>>>
>>>>>>IF !EMPTY( this.control_source )
>>>>>> cAlias = SUBSTR( ALLTRIM(this.control_source), 1, AT('.',ALLTRIM(this.control_source)) - 1)
>>>>>> IF SELECT( cAlias ) > 0
>>>>>> cControlSource = ALLTRIM( this.control_source )
>>>>>> IF EVALUATE( cControlSource ) == OLDVAL( cControlSource )
>>>>>> RETURN .T.
>>>>>> ENDIF
>>>>>> ENDIF
>>>>>>ENDIF
>>>>>>
>>>>>
>>>>>If someone has a test code (any kind of bogus code) that would generate an error
>>>>>
>>>>>ALIAS IS NOT FOUND
>>>>>
>>>>>I would appreciate it!
>>>>
>>>>Is it possible the error actually is [ALIAS '' IS NOT FOUND] i.e. it's a blank/empty alias/work area?
>>>
>>>Yes, this generates the error I was looking for.
>>>
>>>oldval('','')
>>>
>>
>>Now I know that the issue that caused the error message is in the OLDVAL(). And as I determined (above), two empty strings cause the error message ALIAS IS NOT FOUND.
>>In my code, I pass the value in the CONTROL_SOURCE to the OLDVAL(). And the value in CONTROL_SOURCE is "V_WORK.EMPLOYEE" (set at design time).
>>Now I am wondering, how could the value "V_WORK.EMPLOYEE" turn into "'',''" (two empty strings. If anyone has any suggestions, please let me know.
>>UPDATE. Another thing that would cause the error "ALIAS IS NOT FOUND" if the alias V_WORK is closed.
>>But in my code, I do check if the SELECT("V_WORK") > 0. Puzzling.
>
>UPDATE 2. Could the issue be in the quotes around the value in CONTROL_SOURCE? The value set in the CONTROL_SOURCE (at design time) does not have quotes. It is simply V_WORK.EMPLOYEE. Then I pass this value to the OLDVAL. Could it be that sometimes VFP works without quotes and other times require them?