Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetFldState and Alias not found troubles
Message
From
22/10/1997 07:57:27
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00055703
Message ID:
00055974
Views:
49
>>Depending on which field I changed originally, it shows up in a different column. And, yes, it still shows up immediately after tableupdate(). An interesting point, if I change 2 fields and save, it changes the 2 corresponding to the first field to a 1, but no matter how many times I save, the last changed field never has its status changed in getfldstate(-1). And the record REALLY is saved! If I exit the form and go back in, all of my changes are there. BTW, this is not an issue where eval(this.controlsource) this.value. I handle that before invoking my save method.
>>
>>So, what do you think?
>>
>>Marcia
>Marcia,
>
>I'll bet your save button is in a toolbar, right? Well toolbars never get focus, that means that the textbox never lost focus, and the textbox updates its controlsource when it loses focus. So your tableupdate is fired and it updates without the textbox value of the last textbox. Then the textbox loses focus and it updates its controlsource and you have a dirty buffer. The solution, well you did want the answer too didn't you?
>
>In the click of the toolbar button pout this before you tableupdate;
>
> IF TYPE("_screen.activeform.ActiveControl.Name") = "C"
> _screen.activeform.ActiveControl.SetFocus()
> ENDIF
> * The rest of the code here
Hi Jim.

Thanks for the response. And, yes, I did want the answer too! Wouldn't this code work just as well? It seems to be working fine for forms that have only textboxes on them. I put this code in a custom method in my maintenance form base class and it gets invoked before I save.
IF GETFLDSTATE(0) % 2 = 1 AND TYPE("THISFORM.ActiveControl") == "O" AND ;
    UPPER(THISFORM.ActiveControl.BaseClass) <> "GRID"
   IF TYPE("THISFORM.ActiveControl.ControlSource") <> "U" AND ;
      !EMPTY(THISFORM.ActiveControl.ControlSource)
      IF EVAL(THISFORM.ActiveControl.ControlSource) <> THISFORM.ActiveControl.Value
         REPLACE (THISFORM.ActiveControl.ControlSource) WITH THISFORM.ActiveControl.Value
         IF ALLTRIM(EVAL(THISFORM.ActiveControl.ControlSource)) = ALLTRIM(THISFORM.ActiveControl.Value)
            llRetVal = .T.
         ELSE
            llRetVal = .F.
         ENDIF      
      ENDIF
   ENDIF
ENDIF
Actually, I think that Barbara came up with what the problem is. I have a drop down combo on the form that takes has as its control source a field from the table I am updating in the form. But its rowsource is a lookup table that the user can update on the fly. Any time I put code in that did something like "this.value = table.field", I had the problem with getfldstate. I worked around it by changing the code in my IsChanged method to compare oldval to what is in the buffer instead of using getfldstate. My concern was that I had no explanation for why getfldstate didn't seem to be working like it should. Do you know why this phenomenon occurs with the situation I just described?

Best Regards.

Marcia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform